From d2a8d2dfd783541e682cad15ec70ae277a036635 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 10 Mar 2013 18:42:28 -0400 Subject: avoid ugly alert caused by trying to push to unavailable removable drive --- Assistant/Threads/Pusher.hs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Assistant/Threads/Pusher.hs b/Assistant/Threads/Pusher.hs index 8a695316e..d87aa8d3b 100644 --- a/Assistant/Threads/Pusher.hs +++ b/Assistant/Threads/Pusher.hs @@ -38,13 +38,22 @@ pushThread = namedThread "Pusher" $ runEvery (Seconds 2) <~> do commits <- getCommits -- Now see if now's a good time to push. if shouldPush commits - then void $ pushToRemotes True - =<< filter (not . Remote.readonly) . syncGitRemotes - <$> getDaemonStatus + then void $ pushToRemotes True =<< pushTargets else do debug ["delaying push of", show (length commits), "commits"] refillCommits commits +{- We want to avoid pushing to remotes that are marked readonly. + - + - Also, avoid pushing to local remotes we can easily tell are not available, + - to avoid ugly messages when a removable drive is not attached. + -} +pushTargets :: Assistant [Remote] +pushTargets = liftIO . filterM available =<< candidates <$> getDaemonStatus + where + candidates = filter (not . Remote.readonly) . syncGitRemotes + available = maybe (return True) doesDirectoryExist . Remote.localpath + {- Decide if now is a good time to push to remotes. - - Current strategy: Immediately push all commits. The commit machinery -- cgit v1.2.3