From 8a796cfa64264f615e3054ccbd4922bb44718a02 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 4 Sep 2012 15:54:30 -0400 Subject: improve syncing support for special remotes Avoid trying to git push/pull to special remotes, but still do transfer scans of them, after git pull from any other remotes, so we know about any values that have been placed on them. --- Assistant/Sync.hs | 21 +++++++++++++-------- Assistant/Threads/NetWatcher.hs | 7 +++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Assistant/Sync.hs b/Assistant/Sync.hs index 499fc960c..9ba7f406f 100644 --- a/Assistant/Sync.hs +++ b/Assistant/Sync.hs @@ -19,6 +19,7 @@ import qualified Git import qualified Git.Branch import qualified Git.Command import qualified Remote +import qualified Types.Remote as Remote import qualified Annex.Branch import Data.Time.Clock @@ -36,18 +37,22 @@ reconnectRemotes :: ThreadName -> ThreadState -> DaemonStatusHandle -> ScanRemot reconnectRemotes _ _ _ _ [] = noop reconnectRemotes threadname st dstatus scanremotes rs = void $ alertWhile dstatus (syncAlert rs) $ do - sync =<< runThreadState st (inRepo Git.Branch.current) + (ok, diverged) <- sync + =<< runThreadState st (inRepo Git.Branch.current) + addScanRemotes scanremotes diverged rs + return ok where + (gitremotes, specialremotes) = + partition (Git.repoIsUrl . Remote.repo) rs sync (Just branch) = do - diverged <- manualPull st (Just branch) rs - addScanRemotes scanremotes diverged rs - now <- getCurrentTime - pushToRemotes threadname now st Nothing rs + diverged <- manualPull st (Just branch) gitremotes + now <- getCurrentTime + ok <- pushToRemotes threadname now st Nothing gitremotes + return (ok, diverged) {- No local branch exists yet, but we can try pulling. -} sync Nothing = do - diverged <- manualPull st Nothing rs - addScanRemotes scanremotes diverged rs - return True + diverged <- manualPull st Nothing gitremotes + return (True, diverged) {- Updates the local sync branch, then pushes it to all remotes, in - parallel. diff --git a/Assistant/Threads/NetWatcher.hs b/Assistant/Threads/NetWatcher.hs index 117ab7a20..6f6bd40da 100644 --- a/Assistant/Threads/NetWatcher.hs +++ b/Assistant/Threads/NetWatcher.hs @@ -121,10 +121,9 @@ listenWicdConnections client callback = #endif handleConnection :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> IO () -handleConnection st dstatus scanremotes = do - reconnectRemotes thisThread st dstatus scanremotes =<< - filter (Git.repoIsUrl . Remote.repo) - <$> networkRemotes st +handleConnection st dstatus scanremotes = + reconnectRemotes thisThread st dstatus scanremotes + =<< networkRemotes st {- Finds network remotes. -} networkRemotes :: ThreadState -> IO [Remote] -- cgit v1.2.3