This commit was sponsored by Jochen Bartl on Patreon.
AddUnlockedMatcher,
addUnlockedMatcher,
checkAddUnlockedMatcher,
+ LimitBy(..),
module Types.FileMatcher
) where
* Fix build on Windows with network-3.
* Fix a memory leak introduced in the last release.
+ * add, import: Fix a reversion in 7.20191009 that broke handling
+ of --largerthan and --smallerthan.
-- Joey Hess <id@joeyh.name> Thu, 08 Oct 2020 10:48:17 -0400
annexedMatchingOptions :: [GlobalOption]
annexedMatchingOptions = concat
[ keyMatchingOptions'
- , fileMatchingOptions'
+ , fileMatchingOptions' Limit.LimitAnnexFiles
, combiningOptions
, timeLimitOption
]
]
-- Options to match files which may not yet be annexed.
-fileMatchingOptions :: [GlobalOption]
-fileMatchingOptions = fileMatchingOptions' ++ combiningOptions ++ timeLimitOption
+fileMatchingOptions :: Limit.LimitBy -> [GlobalOption]
+fileMatchingOptions lb = fileMatchingOptions' lb ++ combiningOptions ++ timeLimitOption
-fileMatchingOptions' :: [GlobalOption]
-fileMatchingOptions' =
+fileMatchingOptions' :: Limit.LimitBy -> [GlobalOption]
+fileMatchingOptions' lb =
[ globalSetter Limit.addExclude $ strOption
( long "exclude" <> short 'x' <> metavar paramGlob
<> help "skip files matching the glob pattern"
<> help "limit to files matching the glob pattern"
<> hidden
)
- , globalSetter Limit.addLargerThan $ strOption
+ , globalSetter (Limit.addLargerThan lb) $ strOption
( long "largerthan" <> metavar paramSize
<> help "match files larger than a size"
<> hidden
)
- , globalSetter Limit.addSmallerThan $ strOption
+ , globalSetter (Limit.addSmallerThan lb) $ strOption
( long "smallerthan" <> metavar paramSize
<> help "match files smaller than a size"
<> hidden
cmd :: Command
cmd = notBareRepo $
- withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption, fileMatchingOptions] $
+ withGlobalOptions opts $
command "add" SectionCommon "add files to annex"
paramPaths (seek <$$> optParser)
+ where
+ opts =
+ [ jobsOption
+ , jsonOptions
+ , jsonProgressOption
+ , fileMatchingOptions LimitDiskFiles
+ ]
data AddOptions = AddOptions
{ addThese :: CmdParams
cmd :: Command
cmd = notBareRepo $
- withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption, fileMatchingOptions] $
+ withGlobalOptions opts $
command "import" SectionCommon
"add a tree of files to the repository"
(paramPaths ++ "|BRANCH[:SUBDIR]")
(seek <$$> optParser)
+ where
+ opts =
+ [ jobsOption
+ , jsonOptions
+ , jsonProgressOption
+ -- These options are only used when importing from a
+ -- directory, not from a special remote. So it's ok
+ -- to use LimitDiskFiles.
+ , fileMatchingOptions LimitDiskFiles
+ ]
data ImportOptions
= LocalImportOptions
}
{- Adds a limit to skip files that are too large or too small -}
-addLargerThan :: String -> Annex ()
-addLargerThan = addLimit . limitSize LimitAnnexFiles (>)
+addLargerThan :: LimitBy -> String -> Annex ()
+addLargerThan lb = addLimit . limitSize lb (>)
-addSmallerThan :: String -> Annex ()
-addSmallerThan = addLimit . limitSize LimitAnnexFiles (<)
+addSmallerThan :: LimitBy -> String -> Annex ()
+addSmallerThan lb = addLimit . limitSize lb (<)
limitSize :: LimitBy -> (Maybe Integer -> Maybe Integer -> Bool) -> MkLimit Annex
limitSize lb vs s = case readSize dataUnits s of
look at the size of the annexed file, not of the file on disk, which could
be a small pointer file.
-Rather than being global options, --largerthan and --smallerthan,
-could added by each command, so the command can specify how the size
-should be determined. Finding a way to do that w/o needing to add
-boilerplate to many commands would be best.
+> [[fixed|done]] --[[Joey]]