refactor
This commit is contained in:
parent
4be94c67c7
commit
dc7dc1e179
5 changed files with 24 additions and 31 deletions
17
Remote.hs
17
Remote.hs
|
@ -11,6 +11,8 @@ module Remote (
|
|||
Remote,
|
||||
uuid,
|
||||
name,
|
||||
action,
|
||||
verifiedAction,
|
||||
storeKey,
|
||||
retrieveKeyFile,
|
||||
retrieveKeyFileCheap,
|
||||
|
@ -77,6 +79,21 @@ import Config.DynamicConfig
|
|||
import Git.Types (RemoteName, ConfigKey(..), fromConfigValue)
|
||||
import Utility.Aeson
|
||||
|
||||
{- Runs an action that may throw exceptions, catching and displaying them. -}
|
||||
action :: Annex () -> Annex Bool
|
||||
action a = tryNonAsync a >>= \case
|
||||
Right () -> return True
|
||||
Left e -> do
|
||||
warning (show e)
|
||||
return False
|
||||
|
||||
verifiedAction :: Annex Verification -> Annex (Bool, Verification)
|
||||
verifiedAction a = tryNonAsync a >>= \case
|
||||
Right v -> return (True, v)
|
||||
Left e -> do
|
||||
warning (show e)
|
||||
return (False, UnVerified)
|
||||
|
||||
{- Map from UUIDs of Remotes to a calculated value. -}
|
||||
remoteMap :: (Remote -> v) -> Annex (M.Map UUID v)
|
||||
remoteMap mkv = remoteMap' mkv (pure . mkk)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue