summaryrefslogtreecommitdiff
path: root/Remote/Directory.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/Directory.hs
parenta71c03bc5162916853ff520d5c7c89e849c6a047 (diff)
factored out some useful error catching methods
Diffstat (limited to 'Remote/Directory.hs')
-rw-r--r--Remote/Directory.hs15
1 files changed, 5 insertions, 10 deletions
diff --git a/Remote/Directory.hs b/Remote/Directory.hs
index 6d3a5da7d..b592f41ff 100644
--- a/Remote/Directory.hs
+++ b/Remote/Directory.hs
@@ -8,7 +8,6 @@
module Remote.Directory (remote) where
import qualified Data.ByteString.Lazy.Char8 as L
-import System.IO.Error
import qualified Data.Map as M
import Common.Annex
@@ -72,13 +71,13 @@ store :: FilePath -> Key -> Annex Bool
store d k = do
src <- fromRepo $ gitAnnexLocation k
let dest = dirKey d k
- liftIO $ catchBool $ storeHelper dest $ copyFileExternal src dest
+ liftIO $ catchBoolIO $ storeHelper dest $ copyFileExternal src dest
storeEncrypted :: FilePath -> (Cipher, Key) -> Key -> Annex Bool
storeEncrypted d (cipher, enck) k = do
src <- fromRepo $ gitAnnexLocation k
let dest = dirKey d enck
- liftIO $ catchBool $ storeHelper dest $ encrypt src dest
+ liftIO $ catchBoolIO $ storeHelper dest $ encrypt src dest
where
encrypt src dest = do
withEncryptedContent cipher (L.readFile src) $ L.writeFile dest
@@ -100,12 +99,12 @@ retrieve d k f = liftIO $ copyFileExternal (dirKey d k) f
retrieveEncrypted :: FilePath -> (Cipher, Key) -> FilePath -> Annex Bool
retrieveEncrypted d (cipher, enck) f =
- liftIO $ catchBool $ do
+ liftIO $ catchBoolIO $ do
withDecryptedContent cipher (L.readFile (dirKey d enck)) $ L.writeFile f
return True
remove :: FilePath -> Key -> Annex Bool
-remove d k = liftIO $ catchBool $ do
+remove d k = liftIO $ catchBoolIO $ do
allowWrite dir
removeFile file
removeDirectory dir
@@ -115,8 +114,4 @@ remove d k = liftIO $ catchBool $ do
dir = parentDir file
checkPresent :: FilePath -> Key -> Annex (Either String Bool)
-checkPresent d k = dispatch <$> check
- where
- check = liftIO $ try $ doesFileExist (dirKey d k)
- dispatch (Left e) = Left $ show e
- dispatch (Right v) = Right v
+checkPresent d k = liftIO $ catchMsgIO $ doesFileExist (dirKey d k)