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:
parent
907ca937ab
commit
2edf0506a5
5 changed files with 17 additions and 6 deletions
|
@ -37,6 +37,7 @@ import Types.Group
|
|||
import Types.FileMatcher
|
||||
import Types.GitConfig
|
||||
import Config.GitConfig
|
||||
import Annex.SpecialRemote.Config (preferreddirField)
|
||||
import Git.FilePath
|
||||
import Types.Remote (RemoteConfig)
|
||||
import Types.ProposedAccepted
|
||||
|
@ -157,7 +158,7 @@ preferredContentKeylessTokens pcd =
|
|||
] ++ commonKeylessTokens LimitAnnexFiles
|
||||
where
|
||||
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 pcd =
|
||||
|
|
|
@ -80,6 +80,9 @@ chunksizeField = Accepted "chunksize"
|
|||
embedCredsField :: RemoteConfigField
|
||||
embedCredsField = Accepted "embedcreds"
|
||||
|
||||
preferreddirField :: RemoteConfigField
|
||||
preferreddirField = Accepted "preferreddir"
|
||||
|
||||
exportTreeField :: RemoteConfigField
|
||||
exportTreeField = Accepted "exporttree"
|
||||
|
||||
|
@ -100,6 +103,7 @@ commonFieldParsers =
|
|||
, optionalStringParser sameasUUIDField
|
||||
, optionalStringParser typeField
|
||||
, trueFalseParser autoEnableField False
|
||||
, optionalStringParser preferreddirField
|
||||
]
|
||||
|
||||
{- A remote with sameas-uuid set will inherit these values from the config
|
||||
|
|
|
@ -75,16 +75,20 @@ start o (name:ws) = ifM (isJust <$> findExisting name)
|
|||
perform :: RemoteType -> String -> R.RemoteConfig -> InitRemoteOptions -> CommandPerform
|
||||
perform t name c o = do
|
||||
dummycfg <- liftIO dummyRemoteGitConfig
|
||||
(c', u) <- R.setup t R.Init (sameasu <|> uuidfromuser) Nothing c dummycfg
|
||||
next $ cleanup u name c' o
|
||||
let c' = M.delete uuidField c
|
||||
(c'', u) <- R.setup t R.Init (sameasu <|> uuidfromuser) Nothing c' dummycfg
|
||||
next $ cleanup u name c'' o
|
||||
where
|
||||
uuidfromuser = case fromProposedAccepted <$> M.lookup (Accepted "uuid") c of
|
||||
uuidfromuser = case fromProposedAccepted <$> M.lookup uuidField c of
|
||||
Just s
|
||||
| isUUID s -> Just (toUUID s)
|
||||
| otherwise -> giveup "invalid uuid"
|
||||
Nothing -> Nothing
|
||||
sameasu = toUUID . fromProposedAccepted <$> M.lookup sameasUUIDField c
|
||||
|
||||
uuidField :: R.RemoteConfigField
|
||||
uuidField = Accepted "uuid"
|
||||
|
||||
cleanup :: UUID -> String -> R.RemoteConfig -> InitRemoteOptions -> CommandCleanup
|
||||
cleanup u name c o = do
|
||||
case sameas o of
|
||||
|
|
|
@ -27,6 +27,7 @@ import Types.Export
|
|||
import Types.ProposedAccepted
|
||||
import Types.Crypto
|
||||
import Types.RemoteConfig
|
||||
import Annex.SpecialRemote.Config (exportTreeField)
|
||||
import Remote.Helper.ExportImport
|
||||
import Remote.Helper.Chunked
|
||||
import Remote.Helper.Encryptable (describeEncryption)
|
||||
|
@ -139,7 +140,7 @@ encryptionVariants r = do
|
|||
-- Variant of a remote with exporttree disabled.
|
||||
disableExportTree :: Remote -> Annex Remote
|
||||
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.
|
||||
exportTreeVariant :: Remote -> Annex (Maybe Remote)
|
||||
|
|
|
@ -12,6 +12,7 @@ module Types.StandardGroups where
|
|||
import Types.Remote (RemoteConfig)
|
||||
import Types.Group
|
||||
import Types.ProposedAccepted
|
||||
import Annex.SpecialRemote.Config (preferreddirField)
|
||||
|
||||
import qualified Data.Map as M
|
||||
|
||||
|
@ -72,7 +73,7 @@ associatedDirectory _ SmallArchiveGroup = Just "archive"
|
|||
associatedDirectory _ FullArchiveGroup = Just "archive"
|
||||
associatedDirectory (Just c) PublicGroup = Just $
|
||||
maybe "public" fromProposedAccepted $
|
||||
M.lookup (Accepted "preferreddir") c
|
||||
M.lookup preferreddirField c
|
||||
associatedDirectory Nothing PublicGroup = Just "public"
|
||||
associatedDirectory _ _ = Nothing
|
||||
|
||||
|
|
Loading…
Reference in a new issue