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.
This commit is contained in:
parent
2f75512188
commit
44e1524be5
3 changed files with 19 additions and 5 deletions
|
@ -22,6 +22,7 @@ import Logs.Trust
|
||||||
import Logs.Remote
|
import Logs.Remote
|
||||||
import Logs.PreferredContent
|
import Logs.PreferredContent
|
||||||
import Types.StandardGroups
|
import Types.StandardGroups
|
||||||
|
import Annex.UUID
|
||||||
|
|
||||||
import System.IO.HVFS (SystemFS(..))
|
import System.IO.HVFS (SystemFS(..))
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
@ -29,9 +30,13 @@ import qualified Data.Map as M
|
||||||
import System.Path
|
import System.Path
|
||||||
|
|
||||||
notCurrentRepo :: UUID -> Handler Html -> Handler Html
|
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
|
where
|
||||||
go Nothing = redirect DeleteCurrentRepositoryR
|
go Nothing = error "Unknown UUID"
|
||||||
go (Just _) = a
|
go (Just _) = a
|
||||||
|
|
||||||
getDisableRepositoryR :: UUID -> Handler Html
|
getDisableRepositoryR :: UUID -> Handler Html
|
||||||
|
|
12
Remote.hs
12
Remote.hs
|
@ -168,13 +168,19 @@ prettyListUUIDs uuids = do
|
||||||
prettyUUID :: UUID -> Annex String
|
prettyUUID :: UUID -> Annex String
|
||||||
prettyUUID u = concat <$> prettyListUUIDs [u]
|
prettyUUID u = concat <$> prettyListUUIDs [u]
|
||||||
|
|
||||||
{- Gets the remote associated with a UUID.
|
{- Gets the remote associated with a UUID. -}
|
||||||
- There's no associated remote when this is the UUID of the local repo. -}
|
|
||||||
remoteFromUUID :: UUID -> Annex (Maybe Remote)
|
remoteFromUUID :: UUID -> Annex (Maybe Remote)
|
||||||
remoteFromUUID u = ifM ((==) u <$> getUUID)
|
remoteFromUUID u = ifM ((==) u <$> getUUID)
|
||||||
( return Nothing
|
( 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. -}
|
{- Filters a list of remotes to ones that have the listed uuids. -}
|
||||||
remotesWithUUID :: [Remote] -> [UUID] -> [Remote]
|
remotesWithUUID :: [Remote] -> [UUID] -> [Remote]
|
||||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -21,6 +21,9 @@ git-annex (4.20130921) UNRELEASED; urgency=low
|
||||||
* Send a git-annex user-agent when downloading urls.
|
* Send a git-annex user-agent when downloading urls.
|
||||||
Overridable with --user-agent option.
|
Overridable with --user-agent option.
|
||||||
(Not yet done for S3 or WebDAV due to limitations of libraries used.)
|
(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 <joeyh@debian.org> Sun, 22 Sep 2013 19:42:29 -0400
|
-- Joey Hess <joeyh@debian.org> Sun, 22 Sep 2013 19:42:29 -0400
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue