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.
This commit is contained in:
parent
4abe03635e
commit
8a796cfa64
2 changed files with 16 additions and 12 deletions
|
@ -19,6 +19,7 @@ import qualified Git
|
||||||
import qualified Git.Branch
|
import qualified Git.Branch
|
||||||
import qualified Git.Command
|
import qualified Git.Command
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
|
import qualified Types.Remote as Remote
|
||||||
import qualified Annex.Branch
|
import qualified Annex.Branch
|
||||||
|
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
|
@ -36,18 +37,22 @@ reconnectRemotes :: ThreadName -> ThreadState -> DaemonStatusHandle -> ScanRemot
|
||||||
reconnectRemotes _ _ _ _ [] = noop
|
reconnectRemotes _ _ _ _ [] = noop
|
||||||
reconnectRemotes threadname st dstatus scanremotes rs = void $
|
reconnectRemotes threadname st dstatus scanremotes rs = void $
|
||||||
alertWhile dstatus (syncAlert rs) $ do
|
alertWhile dstatus (syncAlert rs) $ do
|
||||||
sync =<< runThreadState st (inRepo Git.Branch.current)
|
(ok, diverged) <- sync
|
||||||
where
|
=<< runThreadState st (inRepo Git.Branch.current)
|
||||||
sync (Just branch) = do
|
|
||||||
diverged <- manualPull st (Just branch) rs
|
|
||||||
addScanRemotes scanremotes diverged rs
|
addScanRemotes scanremotes diverged rs
|
||||||
|
return ok
|
||||||
|
where
|
||||||
|
(gitremotes, specialremotes) =
|
||||||
|
partition (Git.repoIsUrl . Remote.repo) rs
|
||||||
|
sync (Just branch) = do
|
||||||
|
diverged <- manualPull st (Just branch) gitremotes
|
||||||
now <- getCurrentTime
|
now <- getCurrentTime
|
||||||
pushToRemotes threadname now st Nothing rs
|
ok <- pushToRemotes threadname now st Nothing gitremotes
|
||||||
|
return (ok, diverged)
|
||||||
{- No local branch exists yet, but we can try pulling. -}
|
{- No local branch exists yet, but we can try pulling. -}
|
||||||
sync Nothing = do
|
sync Nothing = do
|
||||||
diverged <- manualPull st Nothing rs
|
diverged <- manualPull st Nothing gitremotes
|
||||||
addScanRemotes scanremotes diverged rs
|
return (True, diverged)
|
||||||
return True
|
|
||||||
|
|
||||||
{- Updates the local sync branch, then pushes it to all remotes, in
|
{- Updates the local sync branch, then pushes it to all remotes, in
|
||||||
- parallel.
|
- parallel.
|
||||||
|
|
|
@ -121,10 +121,9 @@ listenWicdConnections client callback =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
handleConnection :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> IO ()
|
handleConnection :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> IO ()
|
||||||
handleConnection st dstatus scanremotes = do
|
handleConnection st dstatus scanremotes =
|
||||||
reconnectRemotes thisThread st dstatus scanremotes =<<
|
reconnectRemotes thisThread st dstatus scanremotes
|
||||||
filter (Git.repoIsUrl . Remote.repo)
|
=<< networkRemotes st
|
||||||
<$> networkRemotes st
|
|
||||||
|
|
||||||
{- Finds network remotes. -}
|
{- Finds network remotes. -}
|
||||||
networkRemotes :: ThreadState -> IO [Remote]
|
networkRemotes :: ThreadState -> IO [Remote]
|
||||||
|
|
Loading…
Reference in a new issue