summaryrefslogtreecommitdiff
path: root/Command/Drop.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-04-17 13:31:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-04-17 13:31:39 -0400
commit99729065ad220c525b9af09fbe9ac084217aefe7 (patch)
tree6680bf887800ed09f4cdb18aaff0fd53be349bb0 /Command/Drop.hs
parentf10602dba8b61f82a654a0c855b5afe71bd80e0f (diff)
drop --from: When local repository is untrusted, its copy of a file does not count.
Diffstat (limited to 'Command/Drop.hs')
-rw-r--r--Command/Drop.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Command/Drop.hs b/Command/Drop.hs
index 269c4c26b..71f19a828 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -78,12 +78,18 @@ performRemote :: Key -> AssociatedFile -> NumCopies -> Remote -> CommandPerform
performRemote key afile numcopies remote = lockContent key $ do
-- Filter the remote it's being dropped from out of the lists of
-- places assumed to have the key, and places to check.
- -- When the local repo has the key, that's one additional copy.
+ -- When the local repo has the key, that's one additional copy,
+ -- as long asthe local repo is not untrusted.
(remotes, trusteduuids) <- Remote.keyPossibilitiesTrusted key
present <- inAnnex key
u <- getUUID
- let have = filter (/= uuid) $
- if present then u:trusteduuids else trusteduuids
+ trusteduuids' <- if present
+ then ifM ((<= SemiTrusted) <$> lookupTrust u)
+ ( pure (u:trusteduuids)
+ , pure trusteduuids
+ )
+ else pure trusteduuids
+ let have = filter (/= uuid) trusteduuids'
untrusteduuids <- trustGet UnTrusted
let tocheck = filter (/= remote) $
Remote.remotesWithoutUUID remotes (have++untrusteduuids)