a few forgotten remote config fields

preferreddir can be used with any special remote, so its parser needs to
be included in the commonFieldParsers.

initremote with uuid= changed to delete that field, so it does not
need to be included in commonFieldParsers. Note that, existing remotes
initialized before this change will have the field in remote.log.
This will not cause problems parsing, because the value will be
Accepted.

Grepping for 'Accepted "' found these, and I'm pretty sure this is all of
them.
This commit is contained in:
Joey Hess 2020-01-15 11:22:36 -04:00
parent 907ca937ab
commit 2edf0506a5
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 17 additions and 6 deletions

View file

@ -37,6 +37,7 @@ import Types.Group
import Types.FileMatcher import Types.FileMatcher
import Types.GitConfig import Types.GitConfig
import Config.GitConfig import Config.GitConfig
import Annex.SpecialRemote.Config (preferreddirField)
import Git.FilePath import Git.FilePath
import Types.Remote (RemoteConfig) import Types.Remote (RemoteConfig)
import Types.ProposedAccepted import Types.ProposedAccepted
@ -157,7 +158,7 @@ preferredContentKeylessTokens pcd =
] ++ commonKeylessTokens LimitAnnexFiles ] ++ commonKeylessTokens LimitAnnexFiles
where where
preferreddir = maybe "public" fromProposedAccepted $ preferreddir = maybe "public" fromProposedAccepted $
M.lookup (Accepted "preferreddir") =<< (`M.lookup` configMap pcd) =<< repoUUID pcd M.lookup preferreddirField =<< (`M.lookup` configMap pcd) =<< repoUUID pcd
preferredContentKeyedTokens :: PreferredContentData -> [ParseToken (MatchFiles Annex)] preferredContentKeyedTokens :: PreferredContentData -> [ParseToken (MatchFiles Annex)]
preferredContentKeyedTokens pcd = preferredContentKeyedTokens pcd =

View file

@ -80,6 +80,9 @@ chunksizeField = Accepted "chunksize"
embedCredsField :: RemoteConfigField embedCredsField :: RemoteConfigField
embedCredsField = Accepted "embedcreds" embedCredsField = Accepted "embedcreds"
preferreddirField :: RemoteConfigField
preferreddirField = Accepted "preferreddir"
exportTreeField :: RemoteConfigField exportTreeField :: RemoteConfigField
exportTreeField = Accepted "exporttree" exportTreeField = Accepted "exporttree"
@ -100,6 +103,7 @@ commonFieldParsers =
, optionalStringParser sameasUUIDField , optionalStringParser sameasUUIDField
, optionalStringParser typeField , optionalStringParser typeField
, trueFalseParser autoEnableField False , trueFalseParser autoEnableField False
, optionalStringParser preferreddirField
] ]
{- A remote with sameas-uuid set will inherit these values from the config {- A remote with sameas-uuid set will inherit these values from the config

View file

@ -75,16 +75,20 @@ start o (name:ws) = ifM (isJust <$> findExisting name)
perform :: RemoteType -> String -> R.RemoteConfig -> InitRemoteOptions -> CommandPerform perform :: RemoteType -> String -> R.RemoteConfig -> InitRemoteOptions -> CommandPerform
perform t name c o = do perform t name c o = do
dummycfg <- liftIO dummyRemoteGitConfig dummycfg <- liftIO dummyRemoteGitConfig
(c', u) <- R.setup t R.Init (sameasu <|> uuidfromuser) Nothing c dummycfg let c' = M.delete uuidField c
next $ cleanup u name c' o (c'', u) <- R.setup t R.Init (sameasu <|> uuidfromuser) Nothing c' dummycfg
next $ cleanup u name c'' o
where where
uuidfromuser = case fromProposedAccepted <$> M.lookup (Accepted "uuid") c of uuidfromuser = case fromProposedAccepted <$> M.lookup uuidField c of
Just s Just s
| isUUID s -> Just (toUUID s) | isUUID s -> Just (toUUID s)
| otherwise -> giveup "invalid uuid" | otherwise -> giveup "invalid uuid"
Nothing -> Nothing Nothing -> Nothing
sameasu = toUUID . fromProposedAccepted <$> M.lookup sameasUUIDField c sameasu = toUUID . fromProposedAccepted <$> M.lookup sameasUUIDField c
uuidField :: R.RemoteConfigField
uuidField = Accepted "uuid"
cleanup :: UUID -> String -> R.RemoteConfig -> InitRemoteOptions -> CommandCleanup cleanup :: UUID -> String -> R.RemoteConfig -> InitRemoteOptions -> CommandCleanup
cleanup u name c o = do cleanup u name c o = do
case sameas o of case sameas o of

View file

@ -27,6 +27,7 @@ import Types.Export
import Types.ProposedAccepted import Types.ProposedAccepted
import Types.Crypto import Types.Crypto
import Types.RemoteConfig import Types.RemoteConfig
import Annex.SpecialRemote.Config (exportTreeField)
import Remote.Helper.ExportImport import Remote.Helper.ExportImport
import Remote.Helper.Chunked import Remote.Helper.Chunked
import Remote.Helper.Encryptable (describeEncryption) import Remote.Helper.Encryptable (describeEncryption)
@ -139,7 +140,7 @@ encryptionVariants r = do
-- Variant of a remote with exporttree disabled. -- Variant of a remote with exporttree disabled.
disableExportTree :: Remote -> Annex Remote disableExportTree :: Remote -> Annex Remote
disableExportTree r = maybe (error "failed disabling exportree") return disableExportTree r = maybe (error "failed disabling exportree") return
=<< adjustRemoteConfig r (M.delete (Accepted "exporttree")) =<< adjustRemoteConfig r (M.delete exportTreeField)
-- Variant of a remote with exporttree enabled. -- Variant of a remote with exporttree enabled.
exportTreeVariant :: Remote -> Annex (Maybe Remote) exportTreeVariant :: Remote -> Annex (Maybe Remote)

View file

@ -12,6 +12,7 @@ module Types.StandardGroups where
import Types.Remote (RemoteConfig) import Types.Remote (RemoteConfig)
import Types.Group import Types.Group
import Types.ProposedAccepted import Types.ProposedAccepted
import Annex.SpecialRemote.Config (preferreddirField)
import qualified Data.Map as M import qualified Data.Map as M
@ -72,7 +73,7 @@ associatedDirectory _ SmallArchiveGroup = Just "archive"
associatedDirectory _ FullArchiveGroup = Just "archive" associatedDirectory _ FullArchiveGroup = Just "archive"
associatedDirectory (Just c) PublicGroup = Just $ associatedDirectory (Just c) PublicGroup = Just $
maybe "public" fromProposedAccepted $ maybe "public" fromProposedAccepted $
M.lookup (Accepted "preferreddir") c M.lookup preferreddirField c
associatedDirectory Nothing PublicGroup = Just "public" associatedDirectory Nothing PublicGroup = Just "public"
associatedDirectory _ _ = Nothing associatedDirectory _ _ = Nothing