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 | 2a04e215e10469ee3bab5d1a5d6d76b0c35cc46c (patch) | |
tree | 41328caa30ae494316d20e1a5e5909b29aa94516 /Command.hs | |
parent | 53304252ca5483ce80f5a66bb74cc9f0732f65d7 (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 c095a4fb1..478dfdc39 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 |