avoid ugly alert caused by trying to push to unavailable removable drive

This commit is contained in:
Joey Hess 2013-03-10 18:42:28 -04:00
parent 65a4c7966f
commit f27c21eb0c

View file

@ -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