From 44e1524be53373ddbf28d643bedf5455433c2b2e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 29 Sep 2013 14:51:49 -0400 Subject: [PATCH] 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. --- Assistant/WebApp/Configurators/Delete.hs | 9 +++++++-- Remote.hs | 12 +++++++++--- debian/changelog | 3 +++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Assistant/WebApp/Configurators/Delete.hs b/Assistant/WebApp/Configurators/Delete.hs index 4a28cd3474..e7c5313636 100644 --- a/Assistant/WebApp/Configurators/Delete.hs +++ b/Assistant/WebApp/Configurators/Delete.hs @@ -22,6 +22,7 @@ import Logs.Trust import Logs.Remote import Logs.PreferredContent import Types.StandardGroups +import Annex.UUID import System.IO.HVFS (SystemFS(..)) import qualified Data.Text as T @@ -29,9 +30,13 @@ import qualified Data.Map as M import System.Path notCurrentRepo :: UUID -> Handler Html -> Handler Html -notCurrentRepo uuid a = go =<< liftAnnex (Remote.remoteFromUUID uuid) +notCurrentRepo uuid a = do + u <- liftAnnex getUUID + if u == uuid + then redirect DeleteCurrentRepositoryR + else go =<< liftAnnex (Remote.remoteFromUUID uuid) where - go Nothing = redirect DeleteCurrentRepositoryR + go Nothing = error "Unknown UUID" go (Just _) = a getDisableRepositoryR :: UUID -> Handler Html 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] diff --git a/debian/changelog b/debian/changelog index 1379ffc018..9fbeae0a74 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,9 @@ git-annex (4.20130921) UNRELEASED; urgency=low * Send a git-annex user-agent when downloading urls. Overridable with --user-agent option. (Not yet done for S3 or WebDAV due to limitations of libraries used.) + * webapp: Fixed a bug where when a new remote is added, one file + may fail to sync to or from it due to the transferrer process not + yet knowing about the new remote. -- Joey Hess Sun, 22 Sep 2013 19:42:29 -0400