summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-22 14:36:58 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-22 14:36:58 -0400
commit5d577c32a946a070c70ddba192f3d8cf4229b7fa (patch)
tree4b73be8a2afb78fa6ba609c0bb8cda523981c84e
parent68659f49983ca30a3c1a1a3f5e7da003f96741dc (diff)
move some git operations outside the annex monad to avoid blocking other threads
-rw-r--r--Assistant/Sync.hs17
1 files changed, 9 insertions, 8 deletions
diff --git a/Assistant/Sync.hs b/Assistant/Sync.hs
index 68053167a..11d33a54f 100644
--- a/Assistant/Sync.hs
+++ b/Assistant/Sync.hs
@@ -36,12 +36,12 @@ syncRemotes threadname st dstatus scanremotes rs = do
addScanRemotes scanremotes rs
where
sync (Just branch) = do
- runThreadState st $ manualPull (Just branch) rs
+ manualPull st (Just branch) rs
now <- getCurrentTime
pushToRemotes threadname now st Nothing rs
{- No local branch exists yet, but we can try pulling. -}
sync Nothing = do
- runThreadState st $ manualPull Nothing rs
+ manualPull st Nothing rs
return True
{- Updates the local sync branch, then pushes it to all remotes, in
@@ -85,14 +85,15 @@ pushToRemotes threadname now st mpushmap remotes = do
retry branch g rs = do
debug threadname [ "trying manual pull to resolve failed pushes" ]
- runThreadState st $ manualPull (Just branch) rs
+ manualPull st (Just branch) rs
go False (Just branch) g rs
{- Manually pull from remotes and merge their branches. -}
-manualPull :: (Maybe Git.Ref) -> [Remote] -> Annex ()
-manualPull currentbranch remotes = do
+manualPull :: ThreadState -> (Maybe Git.Ref) -> [Remote] -> IO ()
+manualPull st currentbranch remotes = do
+ g <- runThreadState st $ fromRepo id
forM_ remotes $ \r ->
- inRepo $ Git.Command.runBool "fetch" [Param $ Remote.name r]
- Annex.Branch.forceUpdate
+ Git.Command.runBool "fetch" [Param $ Remote.name r] g
+ runThreadState st $ Annex.Branch.forceUpdate
forM_ remotes $ \r ->
- Command.Sync.mergeRemote r currentbranch
+ runThreadState st $ Command.Sync.mergeRemote r currentbranch