From 49b88039e597ec761227d00ddf125f8ebe5c6a4f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 6 Mar 2013 15:09:31 -0400 Subject: assistant: Get back in sync with XMPP remotes after network reconnection, and on startup. Make manualPull send push requests over XMPP. When reconnecting with remotes, those that are XMPP remotes cannot immediately be pulled from and scanned, so instead maintain a set of (probably) desynced remotes, and put XMPP remotes on it. (This set could be used in other ways later, if we can detect we're out of sync with other types of remotes.) The merger handles detecting when a XMPP push is received from a desynced remote, and triggers a scan then, if they have in fact diverged. This has one known bug: A single XMPP remote can have multiple clients behind it. When this happens, only the UUID of one client is recorded as the UUID of the XMPP remote. Pushes from the other XMPP clients will not trigger a scan. If the client whose UUID is expected responds to the push request, it'll work, but when that client is offline, we're SOL. --- Annex/TaggedPush.hs | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Annex/TaggedPush.hs (limited to 'Annex') diff --git a/Annex/TaggedPush.hs b/Annex/TaggedPush.hs new file mode 100644 index 000000000..f54ce756f --- /dev/null +++ b/Annex/TaggedPush.hs @@ -0,0 +1,47 @@ +{- git-annex uuid-tagged pushes + - + - Copyright 2012 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Annex.TaggedPush where + +import Common.Annex +import qualified Remote +import qualified Annex.Branch +import qualified Git +import qualified Git.Ref +import qualified Git.Command + +{- Converts a git branch into a branch that is tagged with a UUID, typically + - the UUID of the repo that will be pushing it. + - + - Pushing to branches on the remote that have out uuid in them is ugly, + - but it reserves those branches for pushing by us, and so our pushes will + - never conflict with other pushes. + - + - To avoid cluttering up the branch display, the branch is put under + - refs/synced/, rather than the usual refs/remotes/ + -} +toTaggedBranch :: UUID -> Git.Branch -> Git.Branch +toTaggedBranch u b = Git.Ref $ concat + [ s + , ":" + , "refs/synced/" ++ fromUUID u ++ "/" ++ s + ] + where + s = show $ Git.Ref.base b + +branchTaggedBy :: Git.Branch -> Maybe UUID +branchTaggedBy b = case split "/" $ show b of + ("refs":"synced":u:_base) -> Just $ toUUID u + _ -> Nothing + +taggedPush :: UUID -> Git.Ref -> Remote -> Git.Repo -> IO Bool +taggedPush u branch remote = Git.Command.runBool + [ Param "push" + , Param $ Remote.name remote + , Param $ show $ toTaggedBranch u Annex.Branch.name + , Param $ show $ toTaggedBranch u branch + ] -- cgit v1.2.3