summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-06 15:09:31 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-06 15:09:31 -0400
commit49b88039e597ec761227d00ddf125f8ebe5c6a4f (patch)
tree660cbf757c53229b12629f0da29a0d405a95bed2 /Annex
parent32743077f40eeb21eb3fc230c1d2a46b1b1181e4 (diff)
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.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/TaggedPush.hs47
1 files changed, 47 insertions, 0 deletions
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 <joey@kitenet.net>
+ -
+ - 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
+ ]