support standard and groupwanted in keyless mode
Only when the preferred content expression includes them will a parse failure due to them needing keys result in the preferred content expression not parsing in keyless mode.
This commit is contained in:
parent
5266da2cdd
commit
354c0eb57f
3 changed files with 26 additions and 22 deletions
|
@ -122,8 +122,8 @@ commonKeyedTokens =
|
|||
]
|
||||
|
||||
data PreferredContentData = PCD
|
||||
{ matchStandard :: FileMatcher Annex
|
||||
, matchGroupWanted :: FileMatcher Annex
|
||||
{ matchStandard :: Either String (FileMatcher Annex)
|
||||
, matchGroupWanted :: Either String (FileMatcher Annex)
|
||||
, getGroupMap :: Annex GroupMap
|
||||
, configMap :: M.Map UUID RemoteConfig
|
||||
, repoUUID :: Maybe UUID
|
||||
|
@ -137,7 +137,9 @@ data PreferredContentData = PCD
|
|||
-- so the Key is not known.
|
||||
preferredContentKeylessTokens :: PreferredContentData -> [ParseToken (MatchFiles Annex)]
|
||||
preferredContentKeylessTokens pcd =
|
||||
[ SimpleToken "inpreferreddir" (simply $ limitInDir preferreddir)
|
||||
[ SimpleToken "standard" (call $ matchStandard pcd)
|
||||
, SimpleToken "groupwanted" (call $ matchGroupWanted pcd)
|
||||
, SimpleToken "inpreferreddir" (simply $ limitInDir preferreddir)
|
||||
] ++ commonKeylessTokens
|
||||
where
|
||||
preferreddir = fromMaybe "public" $
|
||||
|
@ -145,9 +147,7 @@ preferredContentKeylessTokens pcd =
|
|||
|
||||
preferredContentKeyedTokens :: PreferredContentData -> [ParseToken (MatchFiles Annex)]
|
||||
preferredContentKeyedTokens pcd =
|
||||
[ SimpleToken "standard" (call $ matchStandard pcd)
|
||||
, SimpleToken "groupwanted" (call $ matchGroupWanted pcd)
|
||||
, SimpleToken "present" (simply $ limitPresent $ repoUUID pcd)
|
||||
[ SimpleToken "present" (simply $ limitPresent $ repoUUID pcd)
|
||||
, SimpleToken "securehash" (simply limitSecureHash)
|
||||
, ValueToken "copies" (usev limitCopies)
|
||||
, ValueToken "lackingcopies" (usev $ limitLackingCopies False)
|
||||
|
@ -215,6 +215,7 @@ simply = Right . Operation
|
|||
usev :: MkLimit Annex -> String -> ParseResult (MatchFiles Annex)
|
||||
usev a v = Operation <$> a v
|
||||
|
||||
call :: FileMatcher Annex -> ParseResult (MatchFiles Annex)
|
||||
call sub = Right $ Operation $ \notpresent mi ->
|
||||
call :: Either String (FileMatcher Annex) -> ParseResult (MatchFiles Annex)
|
||||
call (Right sub) = Right $ Operation $ \notpresent mi ->
|
||||
matchMrun sub $ \a -> a notpresent mi
|
||||
call (Left err) = Left err
|
||||
|
|
|
@ -79,8 +79,8 @@ seek o = do
|
|||
else do
|
||||
u <- getUUID
|
||||
pure $ preferredContentParser $ preferredContentTokens $ PCD
|
||||
{ matchStandard = matchAll
|
||||
, matchGroupWanted = matchAll
|
||||
{ matchStandard = Right matchAll
|
||||
, matchGroupWanted = Right matchAll
|
||||
, getGroupMap = groupMap
|
||||
, configMap = M.empty
|
||||
, repoUUID = Just u
|
||||
|
|
|
@ -73,9 +73,12 @@ preferredRequiredMapsLoad :: (PreferredContentData -> [ParseToken (MatchFiles An
|
|||
preferredRequiredMapsLoad mktokens = do
|
||||
groupmap <- groupMap
|
||||
configmap <- readRemoteLog
|
||||
let genmap l gm = simpleMap
|
||||
. parseLogOldWithUUID (\u -> makeMatcher groupmap configmap gm u mktokens . decodeBS <$> A.takeByteString)
|
||||
<$> Annex.Branch.get l
|
||||
let genmap l gm =
|
||||
let mk u = fromRight (unknownMatcher u) .
|
||||
makeMatcher groupmap configmap gm u mktokens
|
||||
in simpleMap
|
||||
. parseLogOldWithUUID (\u -> mk u . decodeBS <$> A.takeByteString)
|
||||
<$> Annex.Branch.get l
|
||||
pc <- genmap preferredContentLog =<< groupPreferredContentMapRaw
|
||||
rc <- genmap requiredContentLog M.empty
|
||||
-- Required content is implicitly also preferred content, so
|
||||
|
@ -97,12 +100,12 @@ makeMatcher
|
|||
-> UUID
|
||||
-> (PreferredContentData -> [ParseToken (MatchFiles Annex)])
|
||||
-> PreferredContentExpression
|
||||
-> FileMatcher Annex
|
||||
-> Either String (FileMatcher Annex)
|
||||
makeMatcher groupmap configmap groupwantedmap u mktokens = go True True
|
||||
where
|
||||
go expandstandard expandgroupwanted expr
|
||||
| null (lefts tokens) = generate $ rights tokens
|
||||
| otherwise = unknownMatcher u
|
||||
| null (lefts tokens) = Right $ generate $ rights tokens
|
||||
| otherwise = Left (unwords (lefts tokens))
|
||||
where
|
||||
tokens = preferredContentParser (mktokens pcd) expr
|
||||
pcd = PCD
|
||||
|
@ -113,13 +116,13 @@ makeMatcher groupmap configmap groupwantedmap u mktokens = go True True
|
|||
, repoUUID = Just u
|
||||
}
|
||||
matchstandard
|
||||
| expandstandard = maybe (unknownMatcher u) (go False False)
|
||||
| expandstandard = maybe (Right $ unknownMatcher u) (go False False)
|
||||
(standardPreferredContent <$> getStandardGroup mygroups)
|
||||
| otherwise = unknownMatcher u
|
||||
| otherwise = Right $ unknownMatcher u
|
||||
matchgroupwanted
|
||||
| expandgroupwanted = maybe (unknownMatcher u) (go True False)
|
||||
| expandgroupwanted = maybe (Right $ unknownMatcher u) (go True False)
|
||||
(groupwanted mygroups)
|
||||
| otherwise = unknownMatcher u
|
||||
| otherwise = Right $ unknownMatcher u
|
||||
mygroups = fromMaybe S.empty (u `M.lookup` groupsByUUID groupmap)
|
||||
groupwanted s = case M.elems $ M.filterWithKey (\k _ -> S.member k s) groupwantedmap of
|
||||
[pc] -> Just pc
|
||||
|
@ -144,8 +147,8 @@ checkPreferredContentExpression expr = case parsedToMatcher tokens of
|
|||
where
|
||||
tokens = preferredContentParser (preferredContentTokens pcd) expr
|
||||
pcd = PCD
|
||||
{ matchStandard = matchAll
|
||||
, matchGroupWanted = matchAll
|
||||
{ matchStandard = Right matchAll
|
||||
, matchGroupWanted = Right matchAll
|
||||
, getGroupMap = pure emptyGroupMap
|
||||
, configMap = M.empty
|
||||
, repoUUID = Nothing
|
||||
|
|
Loading…
Reference in a new issue