fix annex.largefiles largerthan/smallerthan bug
Fix bug in handling of annex.largefiles that use largerthan/smallerthan. When adding a modified file, it incorrectly used the file size of the old version of the file, not the current size. That was the only largefiles limit that didn't directly look at the file on disk already. Added a new type to keep straight the two different ways such a limit can be matched. I kind of wanted to extend MatchingFile or FileInfo to indicate that the matcher is supposed to operate on files from disk or annex, but it turned out to be too complex to implement it that way. This also changes the LimitAnnexFiles case when lookupFileKey does not find a key. It used to fall back to statting the file, now it always returns False. I doubt the old code could really get to that point, but if it somehow does, it's better for preferred content matching to be consistent.
This commit is contained in:
parent
3b8c94fcbd
commit
3066bdb1fb
4 changed files with 28 additions and 15 deletions
|
@ -113,14 +113,14 @@ tokenizeMatcher = filter (not . null) . concatMap splitparens . words
|
|||
where
|
||||
splitparens = segmentDelim (`elem` "()")
|
||||
|
||||
commonKeylessTokens :: [ParseToken (MatchFiles Annex)]
|
||||
commonKeylessTokens =
|
||||
commonKeylessTokens :: LimitBy -> [ParseToken (MatchFiles Annex)]
|
||||
commonKeylessTokens lb =
|
||||
[ SimpleToken "anything" (simply limitAnything)
|
||||
, SimpleToken "nothing" (simply limitNothing)
|
||||
, ValueToken "include" (usev limitInclude)
|
||||
, ValueToken "exclude" (usev limitExclude)
|
||||
, ValueToken "largerthan" (usev $ limitSize (>))
|
||||
, ValueToken "smallerthan" (usev $ limitSize (<))
|
||||
, ValueToken "largerthan" (usev $ limitSize lb (>))
|
||||
, ValueToken "smallerthan" (usev $ limitSize lb (<))
|
||||
]
|
||||
|
||||
commonKeyedTokens :: [ParseToken (MatchFiles Annex)]
|
||||
|
@ -147,7 +147,7 @@ preferredContentKeylessTokens pcd =
|
|||
[ SimpleToken "standard" (call $ matchStandard pcd)
|
||||
, SimpleToken "groupwanted" (call $ matchGroupWanted pcd)
|
||||
, SimpleToken "inpreferreddir" (simply $ limitInDir preferreddir)
|
||||
] ++ commonKeylessTokens
|
||||
] ++ commonKeylessTokens LimitAnnexFiles
|
||||
where
|
||||
preferreddir = fromMaybe "public" $
|
||||
M.lookup "preferreddir" =<< (`M.lookup` configMap pcd) =<< repoUUID pcd
|
||||
|
@ -182,7 +182,9 @@ mkLargeFilesParser = do
|
|||
let mimer n = ValueToken n $
|
||||
const $ Left $ "\""++n++"\" not supported; not built with MagicMime support"
|
||||
#endif
|
||||
let parse = parseToken $ commonKeyedTokens ++ commonKeylessTokens ++
|
||||
let parse = parseToken $
|
||||
commonKeyedTokens ++
|
||||
commonKeylessTokens LimitDiskFiles ++
|
||||
#ifdef WITH_MAGICMIME
|
||||
[ mimer "mimetype" $
|
||||
matchMagic "mimetype" getMagicMimeType providedMimeType
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue