summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-12 12:45:16 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-12 12:45:16 -0400
commit5fecd2cab5c4d92c2260ecb73319f59d869a256d (patch)
tree2da924c5730f1ff7104a8635286b9ce5c1ee5136
parent078cdfc58d4083a19fa5f933e2e771d32475a48b (diff)
hook up syncing toggles
Although I observe that these toggles don't always prevent syncing. When a transfer scan is active, it will still queue items from the disabled remote. Also, transfers from a disabled remote show up as from "unknown", which is not ideal.
-rw-r--r--Remote.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Remote.hs b/Remote.hs
index b067fa749..e1ff9e7d8 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -27,6 +27,7 @@ module Remote (
byCost,
prettyPrintUUIDs,
prettyListUUIDs,
+ repoFromUUID,
remotesWithUUID,
remotesWithoutUUID,
keyLocations,
@@ -52,6 +53,7 @@ import Logs.UUID
import Logs.Trust
import Logs.Location
import Remote.List
+import qualified Git
{- Map from UUIDs of Remotes to a calculated value. -}
remoteMap :: (Remote -> a) -> Annex (M.Map UUID a)
@@ -145,6 +147,17 @@ prettyListUUIDs uuids = do
where
n = finddescription m u
+{- Gets the git repo associated with a UUID.
+ - There's no associated remote when this is the UUID of the local repo. -}
+repoFromUUID :: UUID -> Annex (Git.Repo, Maybe Remote)
+repoFromUUID u = ifM ((==) u <$> getUUID)
+ ( (,) <$> gitRepo <*> pure Nothing
+ , do
+ remote <- fromMaybe (error "Unknown UUID") . M.lookup u
+ <$> remoteMap id
+ return (repo remote, Just remote)
+ )
+
{- Filters a list of remotes to ones that have the listed uuids. -}
remotesWithUUID :: [Remote] -> [UUID] -> [Remote]
remotesWithUUID rs us = filter (\r -> uuid r `elem` us) rs