simpler way to do this

Remove old code that can be trivially implemented using async in a much
nicer way (that is async exception safe).

I've audited all forkOS calls (except for ones in the assistant),
and this was the last remaining one that is not async exception safe.
The rest look ok to me.
This commit is contained in:
Joey Hess 2020-06-05 14:16:37 -04:00
parent 074260f036
commit 660d8d3a87
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 7 additions and 37 deletions

View file

@ -17,7 +17,6 @@ import Assistant.DaemonStatus
import Assistant.ScanRemotes
import Assistant.RemoteControl
import qualified Command.Sync
import Utility.Parallel
import qualified Git
import qualified Git.Command
import qualified Remote
@ -43,6 +42,7 @@ import Database.Export
import Data.Time.Clock
import qualified Data.Map as M
import Control.Concurrent
import Control.Concurrent.Async
{- Syncs with remotes that may have been disconnected for a while.
-
@ -177,6 +177,11 @@ parallelPush g rs a = do
<*> (Remote.getRepo r >>= \repo ->
sshOptionsTo repo (Remote.gitconfig r) g)
inParallel :: (v -> IO Bool) -> [v] -> IO ([v], [v])
inParallel a l = (\(t,f) -> (map fst t, map fst f))
. partition snd
. zip l <$> mapConcurrently a l
{- Displays an alert while running an action that syncs with some remotes,
- and returns any remotes that it failed to sync with.
-