diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-12 12:45:16 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-12 12:45:16 -0400 |
commit | 5fecd2cab5c4d92c2260ecb73319f59d869a256d (patch) | |
tree | 2da924c5730f1ff7104a8635286b9ce5c1ee5136 | |
parent | 078cdfc58d4083a19fa5f933e2e771d32475a48b (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.hs | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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 |