add, import: Fix a reversion in 7.20191009 that broke handling of --largerthan and --smallerthan
This commit was sponsored by Jochen Bartl on Patreon.
This commit is contained in:
parent
b390a4012c
commit
7036d0a4c1
7 changed files with 34 additions and 17 deletions
|
@ -25,6 +25,7 @@ module Annex.FileMatcher (
|
|||
AddUnlockedMatcher,
|
||||
addUnlockedMatcher,
|
||||
checkAddUnlockedMatcher,
|
||||
LimitBy(..),
|
||||
module Types.FileMatcher
|
||||
) where
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ git-annex (8.20201008) UNRELEASED; urgency=medium
|
|||
|
||||
* 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
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ parseKey = maybe (Fail.fail "invalid key") return . deserializeKey
|
|||
annexedMatchingOptions :: [GlobalOption]
|
||||
annexedMatchingOptions = concat
|
||||
[ keyMatchingOptions'
|
||||
, fileMatchingOptions'
|
||||
, fileMatchingOptions' Limit.LimitAnnexFiles
|
||||
, combiningOptions
|
||||
, timeLimitOption
|
||||
]
|
||||
|
@ -315,11 +315,11 @@ keyMatchingOptions' =
|
|||
]
|
||||
|
||||
-- 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"
|
||||
|
@ -330,12 +330,12 @@ fileMatchingOptions' =
|
|||
<> 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
|
||||
|
|
|
@ -29,9 +29,16 @@ import qualified Utility.RawFilePath as R
|
|||
|
||||
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
|
||||
|
|
|
@ -39,11 +39,21 @@ import Control.Concurrent.STM
|
|||
|
||||
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
|
||||
|
|
8
Limit.hs
8
Limit.hs
|
@ -441,11 +441,11 @@ limitSecureHash = MatchFiles
|
|||
}
|
||||
|
||||
{- 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
|
||||
|
|
|
@ -14,7 +14,4 @@ That commit was otherwise right, eg `git-annex get --largerthan` should
|
|||
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]]
|
||||
|
|
Loading…
Reference in a new issue