avoid false alert about syncing with xmpp remote
This commit is contained in:
parent
1340b9f493
commit
aaec2cbf03
2 changed files with 16 additions and 15 deletions
|
@ -62,7 +62,7 @@ reconnectRemotes notifypushes rs = void $ do
|
||||||
sync (Just branch) = do
|
sync (Just branch) = do
|
||||||
diverged <- snd <$> manualPull (Just branch) gitremotes
|
diverged <- snd <$> manualPull (Just branch) gitremotes
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
ok <- pushToRemotes now notifypushes gitremotes
|
ok <- pushToRemotes' now notifypushes gitremotes
|
||||||
return (ok, diverged)
|
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
|
||||||
|
@ -97,8 +97,16 @@ reconnectRemotes notifypushes rs = void $ do
|
||||||
- reachable. If the fallback fails, the push is queued to be retried
|
- reachable. If the fallback fails, the push is queued to be retried
|
||||||
- later.
|
- later.
|
||||||
-}
|
-}
|
||||||
pushToRemotes :: UTCTime -> Bool -> [Remote] -> Assistant Bool
|
pushToRemotes :: Bool -> [Remote] -> Assistant Bool
|
||||||
pushToRemotes now notifypushes remotes = do
|
pushToRemotes notifypushes remotes = do
|
||||||
|
now <- liftIO $ getCurrentTime
|
||||||
|
let nonxmppremotes = snd $ partition isXMPPRemote remotes
|
||||||
|
let go = pushToRemotes' now notifypushes remotes
|
||||||
|
if null nonxmppremotes
|
||||||
|
then go
|
||||||
|
else alertWhile (pushAlert nonxmppremotes) go
|
||||||
|
pushToRemotes' :: UTCTime -> Bool -> [Remote] -> Assistant Bool
|
||||||
|
pushToRemotes' now notifypushes remotes = do
|
||||||
(g, branch, u) <- liftAnnex $ do
|
(g, branch, u) <- liftAnnex $ do
|
||||||
Annex.Branch.commit "update"
|
Annex.Branch.commit "update"
|
||||||
(,,)
|
(,,)
|
||||||
|
|
|
@ -17,8 +17,6 @@ import Assistant.Sync
|
||||||
import Utility.ThreadScheduler
|
import Utility.ThreadScheduler
|
||||||
import qualified Types.Remote as Remote
|
import qualified Types.Remote as Remote
|
||||||
|
|
||||||
import Data.Time.Clock
|
|
||||||
|
|
||||||
{- This thread retries pushes that failed before. -}
|
{- This thread retries pushes that failed before. -}
|
||||||
pushRetryThread :: NamedThread
|
pushRetryThread :: NamedThread
|
||||||
pushRetryThread = namedThread "PushRetrier" $ runEvery (Seconds halfhour) <~> do
|
pushRetryThread = namedThread "PushRetrier" $ runEvery (Seconds halfhour) <~> do
|
||||||
|
@ -27,9 +25,8 @@ pushRetryThread = namedThread "PushRetrier" $ runEvery (Seconds halfhour) <~> do
|
||||||
topush <- getFailedPushesBefore (fromIntegral halfhour)
|
topush <- getFailedPushesBefore (fromIntegral halfhour)
|
||||||
unless (null topush) $ do
|
unless (null topush) $ do
|
||||||
debug ["retrying", show (length topush), "failed pushes"]
|
debug ["retrying", show (length topush), "failed pushes"]
|
||||||
void $ alertWhile (pushRetryAlert topush) $ do
|
void $ alertWhile (pushRetryAlert topush) $
|
||||||
now <- liftIO $ getCurrentTime
|
pushToRemotes True topush
|
||||||
pushToRemotes now True topush
|
|
||||||
where
|
where
|
||||||
halfhour = 1800
|
halfhour = 1800
|
||||||
|
|
||||||
|
@ -41,13 +38,9 @@ pushThread = namedThread "Pusher" $ runEvery (Seconds 2) <~> do
|
||||||
commits <- getCommits
|
commits <- getCommits
|
||||||
-- Now see if now's a good time to push.
|
-- Now see if now's a good time to push.
|
||||||
if shouldPush commits
|
if shouldPush commits
|
||||||
then do
|
then void $ pushToRemotes True
|
||||||
remotes <- filter (not . Remote.readonly)
|
=<< filter (not . Remote.readonly) . syncGitRemotes
|
||||||
. syncGitRemotes <$> getDaemonStatus
|
<$> getDaemonStatus
|
||||||
unless (null remotes) $
|
|
||||||
void $ alertWhile (pushAlert remotes) $ do
|
|
||||||
now <- liftIO $ getCurrentTime
|
|
||||||
pushToRemotes now True remotes
|
|
||||||
else do
|
else do
|
||||||
debug ["delaying push of", show (length commits), "commits"]
|
debug ["delaying push of", show (length commits), "commits"]
|
||||||
refillCommits commits
|
refillCommits commits
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue