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,
|
||||||
addUnlockedMatcher,
|
addUnlockedMatcher,
|
||||||
checkAddUnlockedMatcher,
|
checkAddUnlockedMatcher,
|
||||||
|
LimitBy(..),
|
||||||
module Types.FileMatcher
|
module Types.FileMatcher
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ git-annex (8.20201008) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* Fix build on Windows with network-3.
|
* Fix build on Windows with network-3.
|
||||||
* Fix a memory leak introduced in the last release.
|
* 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
|
-- 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 :: [GlobalOption]
|
||||||
annexedMatchingOptions = concat
|
annexedMatchingOptions = concat
|
||||||
[ keyMatchingOptions'
|
[ keyMatchingOptions'
|
||||||
, fileMatchingOptions'
|
, fileMatchingOptions' Limit.LimitAnnexFiles
|
||||||
, combiningOptions
|
, combiningOptions
|
||||||
, timeLimitOption
|
, timeLimitOption
|
||||||
]
|
]
|
||||||
|
@ -315,11 +315,11 @@ keyMatchingOptions' =
|
||||||
]
|
]
|
||||||
|
|
||||||
-- Options to match files which may not yet be annexed.
|
-- Options to match files which may not yet be annexed.
|
||||||
fileMatchingOptions :: [GlobalOption]
|
fileMatchingOptions :: Limit.LimitBy -> [GlobalOption]
|
||||||
fileMatchingOptions = fileMatchingOptions' ++ combiningOptions ++ timeLimitOption
|
fileMatchingOptions lb = fileMatchingOptions' lb ++ combiningOptions ++ timeLimitOption
|
||||||
|
|
||||||
fileMatchingOptions' :: [GlobalOption]
|
fileMatchingOptions' :: Limit.LimitBy -> [GlobalOption]
|
||||||
fileMatchingOptions' =
|
fileMatchingOptions' lb =
|
||||||
[ globalSetter Limit.addExclude $ strOption
|
[ globalSetter Limit.addExclude $ strOption
|
||||||
( long "exclude" <> short 'x' <> metavar paramGlob
|
( long "exclude" <> short 'x' <> metavar paramGlob
|
||||||
<> help "skip files matching the glob pattern"
|
<> help "skip files matching the glob pattern"
|
||||||
|
@ -330,12 +330,12 @@ fileMatchingOptions' =
|
||||||
<> help "limit to files matching the glob pattern"
|
<> help "limit to files matching the glob pattern"
|
||||||
<> hidden
|
<> hidden
|
||||||
)
|
)
|
||||||
, globalSetter Limit.addLargerThan $ strOption
|
, globalSetter (Limit.addLargerThan lb) $ strOption
|
||||||
( long "largerthan" <> metavar paramSize
|
( long "largerthan" <> metavar paramSize
|
||||||
<> help "match files larger than a size"
|
<> help "match files larger than a size"
|
||||||
<> hidden
|
<> hidden
|
||||||
)
|
)
|
||||||
, globalSetter Limit.addSmallerThan $ strOption
|
, globalSetter (Limit.addSmallerThan lb) $ strOption
|
||||||
( long "smallerthan" <> metavar paramSize
|
( long "smallerthan" <> metavar paramSize
|
||||||
<> help "match files smaller than a size"
|
<> help "match files smaller than a size"
|
||||||
<> hidden
|
<> hidden
|
||||||
|
|
|
@ -29,9 +29,16 @@ import qualified Utility.RawFilePath as R
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = notBareRepo $
|
cmd = notBareRepo $
|
||||||
withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption, fileMatchingOptions] $
|
withGlobalOptions opts $
|
||||||
command "add" SectionCommon "add files to annex"
|
command "add" SectionCommon "add files to annex"
|
||||||
paramPaths (seek <$$> optParser)
|
paramPaths (seek <$$> optParser)
|
||||||
|
where
|
||||||
|
opts =
|
||||||
|
[ jobsOption
|
||||||
|
, jsonOptions
|
||||||
|
, jsonProgressOption
|
||||||
|
, fileMatchingOptions LimitDiskFiles
|
||||||
|
]
|
||||||
|
|
||||||
data AddOptions = AddOptions
|
data AddOptions = AddOptions
|
||||||
{ addThese :: CmdParams
|
{ addThese :: CmdParams
|
||||||
|
|
|
@ -39,11 +39,21 @@ import Control.Concurrent.STM
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = notBareRepo $
|
cmd = notBareRepo $
|
||||||
withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption, fileMatchingOptions] $
|
withGlobalOptions opts $
|
||||||
command "import" SectionCommon
|
command "import" SectionCommon
|
||||||
"add a tree of files to the repository"
|
"add a tree of files to the repository"
|
||||||
(paramPaths ++ "|BRANCH[:SUBDIR]")
|
(paramPaths ++ "|BRANCH[:SUBDIR]")
|
||||||
(seek <$$> optParser)
|
(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
|
data ImportOptions
|
||||||
= LocalImportOptions
|
= 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 -}
|
{- Adds a limit to skip files that are too large or too small -}
|
||||||
addLargerThan :: String -> Annex ()
|
addLargerThan :: LimitBy -> String -> Annex ()
|
||||||
addLargerThan = addLimit . limitSize LimitAnnexFiles (>)
|
addLargerThan lb = addLimit . limitSize lb (>)
|
||||||
|
|
||||||
addSmallerThan :: String -> Annex ()
|
addSmallerThan :: LimitBy -> String -> Annex ()
|
||||||
addSmallerThan = addLimit . limitSize LimitAnnexFiles (<)
|
addSmallerThan lb = addLimit . limitSize lb (<)
|
||||||
|
|
||||||
limitSize :: LimitBy -> (Maybe Integer -> Maybe Integer -> Bool) -> MkLimit Annex
|
limitSize :: LimitBy -> (Maybe Integer -> Maybe Integer -> Bool) -> MkLimit Annex
|
||||||
limitSize lb vs s = case readSize dataUnits s of
|
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
|
look at the size of the annexed file, not of the file on disk, which could
|
||||||
be a small pointer file.
|
be a small pointer file.
|
||||||
|
|
||||||
Rather than being global options, --largerthan and --smallerthan,
|
> [[fixed|done]] --[[Joey]]
|
||||||
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.
|
|
||||||
|
|
Loading…
Reference in a new issue