summaryrefslogtreecommitdiff
path: root/Remote.hs
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2013-09-29 14:51:49 -0400
committerJoey Hess <joey@kitenet.net>2013-09-29 14:51:49 -0400
commit44e1524be53373ddbf28d643bedf5455433c2b2e (patch)
treeac8a5fd1c8dba4f924ae263befffb29ccd5b81dd /Remote.hs
parent2f7551218829b80ad515c1b8ed5d70908b622d66 (diff)
webapp: Fixed a bug where when a new remote is added, one file may fail to sync to or from it
This happened because the transferrer process did not know about the new remote. remoteFromUUID crashed, which crashed the transferrer. When it was restarted, the new one knew about the new remote so all further files would transfer, but the one file would temporarily not be, until transfers retried. Fixed by making remoteFromUUID not crash, and try reloading the remote list if it does not know about a remote. Note that this means that remoteFromUUID does not only return Nothing anymore when the UUID is the UUID of the local repository. So had to change some code that dependend on that assumption.
Diffstat (limited to 'Remote.hs')
-rw-r--r--Remote.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Remote.hs b/Remote.hs
index 0638e65b06..8b88a75d99 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -168,13 +168,19 @@ prettyListUUIDs uuids = do
prettyUUID :: UUID -> Annex String
prettyUUID u = concat <$> prettyListUUIDs [u]
-{- Gets the remote associated with a UUID.
- - There's no associated remote when this is the UUID of the local repo. -}
+{- Gets the remote associated with a UUID. -}
remoteFromUUID :: UUID -> Annex (Maybe Remote)
remoteFromUUID u = ifM ((==) u <$> getUUID)
( return Nothing
- , Just . fromMaybe (error "Unknown UUID") . M.lookup u <$> remoteMap id
+ , do
+ maybe tryharder (return . Just) =<< findinmap
)
+ where
+ findinmap = M.lookup u <$> remoteMap id
+ {- Re-read remote list in case a new remote has popped up. -}
+ tryharder = do
+ void remoteListRefresh
+ findinmap
{- Filters a list of remotes to ones that have the listed uuids. -}
remotesWithUUID :: [Remote] -> [UUID] -> [Remote]