summaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-12-29 16:21:38 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-12-29 16:21:38 -0400
commitd475aac37544d9442fe6ca6af5e949fd48d3bc96 (patch)
treef1733e539e6b6937b0e119ffd09a4f35a98f0287 /Backend
parent39d0bcb79332426ac9e20f15614a8eef57a8e7d2 (diff)
refactor
Diffstat (limited to 'Backend')
-rw-r--r--Backend/File.hs17
1 files changed, 6 insertions, 11 deletions
diff --git a/Backend/File.hs b/Backend/File.hs
index 092cf7e73..f9a3dbfcb 100644
--- a/Backend/File.hs
+++ b/Backend/File.hs
@@ -16,7 +16,6 @@ module Backend.File (backend, checkKey) where
import Control.Monad.State
import System.Directory
-import Data.List (intersect)
import TypeInternals
import LocationLog
@@ -50,7 +49,8 @@ dummyStore _ _ = return True
- and copy it over to this one. -}
copyKeyFile :: Key -> FilePath -> Annex Bool
copyKeyFile key file = do
- remotes <- Remotes.keyPossibilities key
+ (trusted, untrusted) <- Remotes.keyPossibilities key
+ let remotes = trusted ++ untrusted
if null remotes
then do
showNote "not available"
@@ -92,16 +92,11 @@ 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 trustedcopies = length $ intersect locations trusted
- remotes <- Remotes.keyPossibilities key
- untrustedremotes <- reposWithoutUUID remotes trusted
+ (trusted, untrusted) <- Remotes.keyPossibilities key
numcopies <- getNumCopies numcopiesM
- if numcopies > length untrustedremotes
- then notEnoughCopies numcopies (length untrustedremotes) []
- else findcopies numcopies trustedcopies untrustedremotes []
+ if numcopies > length untrusted
+ then notEnoughCopies numcopies (length untrusted) []
+ else findcopies numcopies (length trusted) untrusted []
where
findcopies need have [] bad
| have >= need = return True