diff options
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/Threads/Merger.hs | 2 | ||||
-rw-r--r-- | Assistant/Threads/MountWatcher.hs | 25 | ||||
-rw-r--r-- | Assistant/Threads/Pusher.hs | 2 |
3 files changed, 16 insertions, 13 deletions
diff --git a/Assistant/Threads/Merger.hs b/Assistant/Threads/Merger.hs index c79566349..6e19218d9 100644 --- a/Assistant/Threads/Merger.hs +++ b/Assistant/Threads/Merger.hs @@ -89,7 +89,7 @@ mergeBranch = Git.Merge.mergeNonInteractive . Command.Sync.syncBranch - when a push fails, which can happen due to a remote not having pushed - changes to us. That could be because it doesn't have us as a remote, or - because the assistant is not running there, or other reasons. -} -manualPull :: Git.Ref -> [Remote] -> Annex () +manualPull :: (Maybe Git.Ref) -> [Remote] -> Annex () manualPull currentbranch remotes = do forM_ remotes $ \r -> inRepo $ Git.Command.runBool "fetch" [Param $ Remote.name r] diff --git a/Assistant/Threads/MountWatcher.hs b/Assistant/Threads/MountWatcher.hs index ca359a268..18dfca42c 100644 --- a/Assistant/Threads/MountWatcher.hs +++ b/Assistant/Threads/MountWatcher.hs @@ -161,18 +161,21 @@ handleMount st dstatus scanremotes dir = do debug thisThread ["detected mount of", dir] rs <- remotesUnder st dstatus dir unless (null rs) $ do - go rs =<< runThreadState st (inRepo Git.Branch.current) + let nonspecial = filter (Git.repoIsLocal . Remote.repo) rs + unless (null nonspecial) $ do + void $ alertWhile dstatus (syncMountAlert dir nonspecial) $ do + debug thisThread ["syncing with", show rs] + sync nonspecial =<< runThreadState st (inRepo Git.Branch.current) + addScanRemotes scanremotes nonspecial where - go _ Nothing = noop - go rs (Just branch) = do - let nonspecial = filter (Git.repoIsLocal . Remote.repo) rs - unless (null nonspecial) $ - void $ alertWhile dstatus (syncMountAlert dir nonspecial) $ do - debug thisThread ["syncing with", show nonspecial] - runThreadState st $ manualPull branch nonspecial - now <- getCurrentTime - pushToRemotes thisThread now st Nothing nonspecial - addScanRemotes scanremotes rs + sync rs (Just branch) = do + runThreadState st $ manualPull (Just branch) rs + now <- getCurrentTime + pushToRemotes thisThread now st Nothing rs + {- No local branch exists yet, but we can try pulling. -} + sync rs Nothing = do + runThreadState st $ manualPull Nothing rs + return True {- Finds remotes located underneath the mount point. - diff --git a/Assistant/Threads/Pusher.hs b/Assistant/Threads/Pusher.hs index 5e110b77d..4753e355a 100644 --- a/Assistant/Threads/Pusher.hs +++ b/Assistant/Threads/Pusher.hs @@ -118,5 +118,5 @@ pushToRemotes threadname now st mpushmap remotes = do retry branch g rs = do debug threadname [ "trying manual pull to resolve failed pushes" ] - runThreadState st $ manualPull branch rs + runThreadState st $ manualPull (Just branch) rs go False (Just branch) g rs |