avoid ugly alert caused by trying to push to unavailable removable drive
This commit is contained in:
parent
65a4c7966f
commit
f27c21eb0c
1 changed files with 12 additions and 3 deletions
|
@ -38,13 +38,22 @@ 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 void $ pushToRemotes True
|
then void $ pushToRemotes True =<< pushTargets
|
||||||
=<< filter (not . Remote.readonly) . syncGitRemotes
|
|
||||||
<$> getDaemonStatus
|
|
||||||
else do
|
else do
|
||||||
debug ["delaying push of", show (length commits), "commits"]
|
debug ["delaying push of", show (length commits), "commits"]
|
||||||
refillCommits 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.
|
{- Decide if now is a good time to push to remotes.
|
||||||
-
|
-
|
||||||
- Current strategy: Immediately push all commits. The commit machinery
|
- Current strategy: Immediately push all commits. The commit machinery
|
||||||
|
|
Loading…
Add table
Reference in a new issue