diff options
author | Joey Hess <joeyh@joeyh.name> | 2019-05-14 14:59:03 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2019-05-14 14:59:03 -0400 |
commit | 354c0eb57feee593ae037a829a2d4a6861a16e2c (patch) | |
tree | 99871160e504fed0719b63053680388d4a35bebe /Logs | |
parent | 5266da2cdd72ecaf5db4354d6ac35abf4f27f8a4 (diff) |
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.
Diffstat (limited to 'Logs')
-rw-r--r-- | Logs/PreferredContent.hs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Logs/PreferredContent.hs b/Logs/PreferredContent.hs index c36fb3ea73..16ffef1297 100644 --- a/Logs/PreferredContent.hs +++ b/Logs/PreferredContent.hs @@ -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 |