summaryrefslogtreecommitdiff
path: root/Backend/File.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-12-28 17:17:02 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-12-28 17:17:02 -0400
commitaa4f91b2d67b9f7827b02acebfbf4e67ba33bb80 (patch)
treeb81d1dea5915cc6aad1b9d0efc911fc1b9bbbe9a /Backend/File.hs
parent6c58a58393a1d6d2257cb9e72e534387561943d7 (diff)
Add trust and untrust subcommands, to allow configuring remotes that are trusted to retain files without explicit checking.
Diffstat (limited to 'Backend/File.hs')
-rw-r--r--Backend/File.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Backend/File.hs b/Backend/File.hs
index f88bb7c70..0b1cdd8e5 100644
--- a/Backend/File.hs
+++ b/Backend/File.hs
@@ -16,6 +16,7 @@ module Backend.File (backend, checkKey) where
import Control.Monad.State
import System.Directory
+import Data.List (intersect)
import TypeInternals
import LocationLog
@@ -91,11 +92,16 @@ checkRemoveKey key numcopiesM = do
if force || numcopiesM == Just 0
then return True
else do
+ g <- Annex.gitRepo
+ locations <- liftIO $ keyLocations g key
+ trusted <- getTrusted
+ let trustedlocations = intersect locations trusted
remotes <- Remotes.keyPossibilities key
+ untrustedremotes <- reposWithoutUUID remotes trusted
numcopies <- getNumCopies numcopiesM
- if numcopies > length remotes
- then notEnoughCopies numcopies (length remotes) []
- else findcopies numcopies 0 remotes []
+ if numcopies > length untrustedremotes
+ then notEnoughCopies numcopies (length untrustedremotes) []
+ else findcopies numcopies (length trustedlocations) untrustedremotes []
where
findcopies need have [] bad
| have >= need = return True