diff options
-rw-r--r-- | GitAnnex.hs | 4 | ||||
-rw-r--r-- | Limit.hs | 17 | ||||
-rw-r--r-- | Logs/PreferredContent.hs | 4 | ||||
-rw-r--r-- | debian/changelog | 3 | ||||
-rw-r--r-- | doc/design/assistant/transfer_control.mdwn | 10 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 9 |
6 files changed, 38 insertions, 9 deletions
diff --git a/GitAnnex.hs b/GitAnnex.hs index be5af113d..80a151136 100644 --- a/GitAnnex.hs +++ b/GitAnnex.hs @@ -147,6 +147,10 @@ options = Option.common ++ "skip files with fewer copies" , Option ['B'] ["inbackend"] (ReqArg Limit.addInBackend paramName) "skip files not using a key-value backend" + , Option [] ["largerthan"] (ReqArg Limit.addLargerThan paramName) + "skip files larger than a size" + , Option [] ["smallerthan"] (ReqArg Limit.addSmallerThan paramName) + "skip files smaller than a size" , Option ['T'] ["time-limit"] (ReqArg Limit.addTimeLimit paramTime) "stop after the specified amount of time" ] ++ Option.matcher @@ -21,8 +21,10 @@ import Annex.Content import Annex.UUID import Logs.Trust import Types.TrustLevel +import Types.Key import Logs.Group import Utility.HumanTime +import Utility.DataUnits type MatchFiles = AssumeNotPresent -> FilePath -> Annex Bool type MkLimit = String -> Either String MatchFiles @@ -143,6 +145,21 @@ limitInBackend name = Right $ const $ Backend.lookupFile >=> check wanted = Backend.lookupBackendName name check = return . maybe False ((==) wanted . snd) +{- Adds a limit to skip files that are too large or too small -} +addLargerThan :: String -> Annex () +addLargerThan = addLimit . limitSize (>) + +addSmallerThan :: String -> Annex () +addSmallerThan = addLimit . limitSize (<) + +limitSize :: (Maybe Integer -> Maybe Integer -> Bool) -> MkLimit +limitSize vs s = case readSize dataUnits s of + Nothing -> Left "bad size" + Just sz -> Right $ const $ Backend.lookupFile >=> check sz + where + check _ Nothing = return False + check sz (Just (key, _)) = return $ keySize key `vs` Just sz + addTimeLimit :: String -> Annex () addTimeLimit s = do let seconds = fromMaybe (error "bad time-limit") $ parseDuration s diff --git a/Logs/PreferredContent.hs b/Logs/PreferredContent.hs index 8d812ec4d..3da5cc329 100644 --- a/Logs/PreferredContent.hs +++ b/Logs/PreferredContent.hs @@ -21,7 +21,7 @@ import Common.Annex import qualified Annex.Branch import qualified Annex import Logs.UUIDBased -import Limit (MatchFiles, AssumeNotPresent, limitInclude, limitExclude, limitIn, limitCopies, limitInBackend) +import Limit import qualified Utility.Matcher import Annex.UUID import Git.FilePath @@ -96,6 +96,8 @@ parseToken t , ("in", limitIn) , ("copies", limitCopies) , ("backend", limitInBackend) + , ("largerthan", limitSize (>)) + , ("smallerthan", limitSize (<)) ] use a = Utility.Matcher.Operation <$> a v diff --git a/debian/changelog b/debian/changelog index a3442b1fb..8a0bf2ac5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,7 +12,8 @@ git-annex (3.20121002) UNRELEASED; urgency=low * get --auto, copy --auto: If the local repository has preferred content configured, only get that content. * drop --auto: If the local repository has preferred content configured, - drop content that is not preferred, if numcopies allows. + drop content that is not preferred, when numcopies allows. + * Added --smallerthan and --largerthan limits. * Only build-depend on libghc-clientsession-dev on arches that will have the webapp. * uninit: Unset annex.version. Closes: #689852 diff --git a/doc/design/assistant/transfer_control.mdwn b/doc/design/assistant/transfer_control.mdwn index 204f5d090..e38b0ca97 100644 --- a/doc/design/assistant/transfer_control.mdwn +++ b/doc/design/assistant/transfer_control.mdwn @@ -8,9 +8,9 @@ But often the remote is just a removable drive or a cloud remote, that has a limited size. This page is about making the assistant do something smart with such remotes. -## specifying what data belongs on a remote +## specifying what data a remote prefers to contain **done** -Imagine a per-remote `annex-accept` setting, that matches things that +Imagine a per-remote preferred content setting, that matches things that should be stored on the remote. For example, a MP3 player might use: @@ -23,14 +23,10 @@ A USB drive that is carried between three laptops and used to sync data between them might use: `not (in=laptop1 and in=laptop2 and in=laptop3)` In this case, transferring data from the usb repo should -check if `annex-accept` then rejects the data, and if so, drop it +check if preferred content settings rejects the data, and if so, drop it from the repo. So once all three laptops have the data, it is pruned from the transfer drive. -It may make sense to have annex-accept info also be stored in the git-annex -branch, for settings that should apply to a repo globally. Does it make -sense to have local configuration too? - ## repo groups Seems like git-annex needs a way to know the groups of repos. Some diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index 5c762593e..390d19eaf 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -643,6 +643,15 @@ file contents are present at either of two repositories. Matches only files whose content is stored using the specified key-value backend. +* --smallerthan=size +* --largerthan=size + + Matches only files whose content is smaller than, or larger than the + specified size. + + The size can be specified with any commonly used units, for example, + "0.5 gb" or "100 KiloBytes" + * --not Inverts the next file matching option. For example, to only act on |