summaryrefslogtreecommitdiff
path: root/Remote/Hook.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-10 20:24:24 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-10 20:57:28 -0400
commit49d2177d51b95b4a01c05ee07e166e93751b4c51 (patch)
treeb818865e5a924dc90bf0a79608351b1aeffe458a /Remote/Hook.hs
parenta71c03bc5162916853ff520d5c7c89e849c6a047 (diff)
factored out some useful error catching methods
Diffstat (limited to 'Remote/Hook.hs')
-rw-r--r--Remote/Hook.hs7
1 files changed, 2 insertions, 5 deletions
diff --git a/Remote/Hook.hs b/Remote/Hook.hs
index 9f9250e41..03976fc70 100644
--- a/Remote/Hook.hs
+++ b/Remote/Hook.hs
@@ -9,7 +9,6 @@ module Remote.Hook (remote) where
import qualified Data.ByteString.Lazy.Char8 as L
import qualified Data.Map as M
-import System.IO.Error (try)
import System.Exit
import Common.Annex
@@ -112,7 +111,7 @@ retrieve h k f = runHook h "retrieve" k (Just f) $ return True
retrieveEncrypted :: String -> (Cipher, Key) -> FilePath -> Annex Bool
retrieveEncrypted h (cipher, enck) f = withTmp enck $ \tmp ->
- runHook h "retrieve" enck (Just tmp) $ liftIO $ catchBool $ do
+ runHook h "retrieve" enck (Just tmp) $ liftIO $ catchBoolIO $ do
withDecryptedContent cipher (L.readFile tmp) $ L.writeFile f
return True
@@ -123,12 +122,10 @@ checkPresent :: Git.Repo -> String -> Key -> Annex (Either String Bool)
checkPresent r h k = do
showAction $ "checking " ++ Git.repoDescribe r
v <- lookupHook h "checkpresent"
- dispatch <$> liftIO (try (check v) ::IO (Either IOException Bool))
+ liftIO $ catchMsgIO $ check v
where
findkey s = show k `elem` lines s
env = hookEnv k Nothing
- dispatch (Left e) = Left $ show e
- dispatch (Right v) = Right v
check Nothing = error "checkpresent hook misconfigured"
check (Just hook) = do
(frompipe, topipe) <- createPipe