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:
Joey Hess 2013-09-29 14:51:49 -04:00
parent 2f75512188
commit 44e1524be5
3 changed files with 19 additions and 5 deletions

View file

@ -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