diff options
author | Joey Hess <joey@kitenet.net> | 2012-12-06 13:22:16 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-12-06 13:22:16 -0400 |
commit | 99a8a5297c8141ae45bae4d54cd803707e48284e (patch) | |
tree | d2f9726d099704690dec15802062c34b3292e814 /Command.hs | |
parent | 28cfd6776d82135478e05e572561b7a65af9082f (diff) |
--auto fixes
* get/copy --auto: Transfer data even if it would exceed numcopies,
when preferred content settings want it.
* drop --auto: Fix dropping content when there are no preferred content
settings.
Diffstat (limited to 'Command.hs')
-rw-r--r-- | Command.hs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Command.hs b/Command.hs index c095a4fb15..478dfdc39e 100644 --- a/Command.hs +++ b/Command.hs @@ -20,7 +20,7 @@ module Command ( notBareRepo, isBareRepo, numCopies, - autoCopies, + numCopiesCheck, autoCopiesWith, checkAuto, module ReExported @@ -109,6 +109,13 @@ isBareRepo = fromRepo Git.repoIsLocalBare numCopies :: FilePath -> Annex (Maybe Int) numCopies file = readish <$> checkAttr "annex.numcopies" file +numCopiesCheck :: FilePath -> Key -> (Int -> Int -> Bool) -> Annex Bool +numCopiesCheck file key vs = do + numcopiesattr <- numCopies file + needed <- getNumCopies numcopiesattr + have <- trustExclude UnTrusted =<< Remote.keyLocations key + return $ length have `vs` needed + {- Used for commands that have an auto mode that checks the number of known - copies of a key. - @@ -116,16 +123,6 @@ numCopies file = readish <$> checkAttr "annex.numcopies" file - copies of the key is > or < than the numcopies setting, before running - the action. -} -autoCopies :: FilePath -> Key -> (Int -> Int -> Bool) -> CommandStart -> CommandStart -autoCopies file key vs a = Annex.getState Annex.auto >>= go - where - go False = a - go True = do - numcopiesattr <- numCopies file - needed <- getNumCopies numcopiesattr - have <- trustExclude UnTrusted =<< Remote.keyLocations key - if length have `vs` needed then a else stop - autoCopiesWith :: FilePath -> Key -> (Int -> Int -> Bool) -> (Maybe Int -> CommandStart) -> CommandStart autoCopiesWith file key vs a = do numcopiesattr <- numCopies file |