summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Command.hs18
-rw-r--r--Command/Drop.hs19
-rw-r--r--debian/changelog4
3 files changed, 24 insertions, 17 deletions
diff --git a/Command.hs b/Command.hs
index af38d01ed..55892225b 100644
--- a/Command.hs
+++ b/Command.hs
@@ -21,7 +21,7 @@ module Command (
isBareRepo,
numCopies,
autoCopies,
- autoCopiesDrop,
+ autoCopiesWith,
module ReExported
) where
@@ -40,7 +40,6 @@ import Config
import Annex.CheckAttr
import Logs.PreferredContent
import Git.FilePath
-import Annex.UUID
import qualified Data.Set as S
@@ -135,13 +134,8 @@ autoCopies file key vs a = Annex.getState Annex.auto >>= go
( a, stop )
else stop
-{- For dropping, supplies the number of known copies to the action.
- -
- - In auto mode, checks the number of known copies.
- - Also, checks if the repo would prefer to retain the content.
- -}
-autoCopiesDrop :: FilePath -> Key -> (Int -> Int -> Bool) -> (Maybe Int -> CommandStart) -> CommandStart
-autoCopiesDrop file key vs a = do
+autoCopiesWith :: FilePath -> Key -> (Int -> Int -> Bool) -> (Maybe Int -> CommandStart) -> CommandStart
+autoCopiesWith file key vs a = do
numcopiesattr <- numCopies file
Annex.getState Annex.auto >>= auto numcopiesattr
where
@@ -150,9 +144,5 @@ autoCopiesDrop file key vs a = do
needed <- getNumCopies numcopiesattr
(_, have) <- trustPartition UnTrusted =<< Remote.keyLocations key
if length have `vs` needed
- then do
- fp <- inRepo $ toTopFilePath file
- u <- getUUID
- ifM (isPreferredContent (Just u) (S.singleton u) fp)
- ( stop, a numcopiesattr )
+ then a numcopiesattr
else stop
diff --git a/Command/Drop.hs b/Command/Drop.hs
index 440526347..9640d2804 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -17,6 +17,10 @@ import Logs.Trust
import Annex.Content
import Config
import qualified Option
+import Git.FilePath
+import Logs.PreferredContent
+
+import qualified Data.Set as S
def :: [Command]
def = [withOptions [fromOption] $ command "drop" paramPaths seek
@@ -30,7 +34,7 @@ seek = [withField fromOption Remote.byName $ \from ->
withFilesInGit $ whenAnnexed $ start from]
start :: Maybe Remote -> FilePath -> (Key, Backend) -> CommandStart
-start from file (key, _) = autoCopiesDrop file key (>) $ \numcopies ->
+start from file (key, _) = shouldDrop $ \numcopies ->
case from of
Nothing -> startLocal file numcopies key
Just remote -> do
@@ -38,6 +42,19 @@ start from file (key, _) = autoCopiesDrop file key (>) $ \numcopies ->
if Remote.uuid remote == u
then startLocal file numcopies key
else startRemote file numcopies key remote
+ where
+ {- In --auto mode, drop if there are enough copies,
+ - and the repository being dropped from doesn't prefer
+ - to keep the content. -}
+ shouldDrop a = autoCopiesWith file key (>) $ \numcopies ->
+ ifM (Annex.getState Annex.auto)
+ ( do
+ fp <- inRepo $ toTopFilePath file
+ u <- maybe getUUID (return . Remote.uuid) from
+ ifM (isPreferredContent (Just u) (S.singleton u) fp)
+ ( a numcopies, stop )
+ , a numcopies
+ )
startLocal :: FilePath -> Maybe Int -> Key -> CommandStart
startLocal file numcopies key = stopUnless (inAnnex key) $ do
diff --git a/debian/changelog b/debian/changelog
index ceff1d5f4..9eb137039 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,8 +10,8 @@ git-annex (3.20121002) UNRELEASED; urgency=low
* Added preferred content expressions, configurable using vicfg.
* 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, when numcopies allows.
+ * drop --auto: If the repository the content is dropped from has
+ preferred content configured, drop only content that is not preferred.
* --copies=group:number can now be used to match files that are present
in a specified number of repositories in a group.
* Added --smallerthan, --largerthan, and --inall limits.