aboutsummaryrefslogtreecommitdiff
path: root/Assistant/Drop.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-05 12:44:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-05 12:44:08 -0400
commit3540e34025049ed4420810f21cdad6a5adc851c5 (patch)
tree6ed24edcb6da8d95b15b6191c8c93482f3666210 /Assistant/Drop.hs
parent0517167a9cff40fcdddb0f2997cb729dd2d4fe03 (diff)
assistant: Avoid trying to drop content from remotes that don't have it.
Diffstat (limited to 'Assistant/Drop.hs')
-rw-r--r--Assistant/Drop.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/Assistant/Drop.hs b/Assistant/Drop.hs
index 7b85ece8d..8098300ae 100644
--- a/Assistant/Drop.hs
+++ b/Assistant/Drop.hs
@@ -11,7 +11,7 @@ import Assistant.Common
import Assistant.DaemonStatus
import Logs.Location
import Logs.Trust
-import Types.Remote (AssociatedFile)
+import Types.Remote (AssociatedFile, uuid)
import qualified Remote
import qualified Command.Drop
import Command
@@ -19,6 +19,8 @@ import Annex.Wanted
import Annex.Exception
import Config
+import qualified Data.Set as S
+
{- Drop from local and/or remote when allowed by the preferred content and
- numcopies settings. -}
handleDrops :: Bool -> Key -> AssociatedFile -> Maybe Remote -> Assistant ()
@@ -29,6 +31,10 @@ handleDrops fromhere key f knownpresentremote = do
locs <- loggedLocations key
handleDropsFrom locs syncrs fromhere key f knownpresentremote
+{- The UUIDs are ones where the content is believed to be present.
+ - The Remote list can include other remotes that do not have the content;
+ - only ones that match the UUIDs will be dropped from.
+ - If allows to drop fromhere, that drop will be tried first. -}
handleDropsFrom :: [UUID] -> [Remote] -> Bool -> Key -> AssociatedFile -> Maybe Remote -> Annex ()
handleDropsFrom _ _ _ _ Nothing _ = noop
handleDropsFrom locs rs fromhere key (Just f) knownpresentremote
@@ -48,6 +54,7 @@ handleDropsFrom locs rs fromhere key (Just f) knownpresentremote
go [] _ = noop
go (r:rest) n
+ | uuid r `S.notMember` slocs = go rest n
| checkcopies n = dropr r n >>= go rest
| otherwise = noop
@@ -66,3 +73,5 @@ handleDropsFrom locs rs fromhere key (Just f) knownpresentremote
Command.Drop.startRemote f numcopies key r
safely a = either (const False) id <$> tryAnnex a
+
+ slocs = S.fromList locs