summaryrefslogtreecommitdiff
path: root/Remote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-07-05 18:31:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-07-05 19:57:46 -0400
commit9f1577f74684d8d627e75d3021eb1ff50ef7492f (patch)
tree840a7331189550e93a2ea684bceeb97b4c05b1aa /Remote.hs
parent674768abac3efb2646479c6afba76d9ff27fd802 (diff)
remove unused backend machinery
The only remaining vestiage of backends is different types of keys. These are still called "backends", mostly to avoid needing to change user interface and configuration. But everything to do with storing keys in different backends was gone; instead different types of remotes are used. In the refactoring, lots of code was moved out of odd corners like Backend.File, to closer to where it's used, like Command.Drop and Command.Fsck. Quite a lot of dead code was removed. Several data structures became simpler, which may result in better runtime efficiency. There should be no user-visible changes.
Diffstat (limited to 'Remote.hs')
-rw-r--r--Remote.hs33
1 files changed, 31 insertions, 2 deletions
diff --git a/Remote.hs b/Remote.hs
index 28c2e39cd..623b85733 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -14,10 +14,10 @@ module Remote (
removeKey,
hasKey,
hasKeyCheap,
+
keyPossibilities,
keyPossibilitiesTrusted,
forceTrust,
-
remoteTypes,
genList,
byName,
@@ -25,6 +25,8 @@ module Remote (
remotesWithUUID,
remotesWithoutUUID,
prettyPrintUUIDs,
+ showTriedRemotes,
+ showLocations,
remoteLog,
readRemoteLog,
@@ -40,6 +42,7 @@ import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Char
+import Data.String.Utils
import qualified Branch
import Types
@@ -49,6 +52,7 @@ import qualified Annex
import Config
import Trust
import LocationLog
+import Messages
import qualified Remote.Git
import qualified Remote.S3
@@ -181,9 +185,34 @@ keyPossibilities' withtrusted key = do
return (sort validremotes, validtrusteduuids)
+{- Displays known locations of a key. -}
+showLocations :: Key -> [UUID] -> Annex ()
+showLocations key exclude = do
+ g <- Annex.gitRepo
+ u <- getUUID g
+ uuids <- keyLocations key
+ untrusteduuids <- trustGet UnTrusted
+ let uuidswanted = filteruuids uuids (u:exclude++untrusteduuids)
+ let uuidsskipped = filteruuids uuids (u:exclude++uuidswanted)
+ ppuuidswanted <- Remote.prettyPrintUUIDs uuidswanted
+ ppuuidsskipped <- Remote.prettyPrintUUIDs uuidsskipped
+ showLongNote $ message ppuuidswanted ppuuidsskipped
+ where
+ filteruuids l x = filter (`notElem` x) l
+ message [] [] = "No other repository is known to contain the file."
+ message rs [] = "Try making some of these repositories available:\n" ++ rs
+ message [] us = "Also these untrusted repositories may contain the file:\n" ++ us
+ message rs us = message rs [] ++ message [] us
+
+showTriedRemotes :: [Remote Annex] -> Annex ()
+showTriedRemotes [] = return ()
+showTriedRemotes remotes =
+ showLongNote $ "Unable to access these remotes: " ++
+ (join ", " $ map name remotes)
+
forceTrust :: TrustLevel -> String -> Annex ()
forceTrust level remotename = do
- r <- Remote.nameToUUID remotename
+ r <- nameToUUID remotename
Annex.changeState $ \s ->
s { Annex.forcetrust = (r, level):Annex.forcetrust s }