summaryrefslogtreecommitdiff
path: root/Remote/Helper/Chunked.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-26 23:26:10 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-26 23:26:10 -0400
commit748609e54c6bc6ca9d6ac68da04b8dd430416876 (patch)
tree127be7bfcaa82c00c85b093615f08a0f3c421380 /Remote/Helper/Chunked.hs
parent24c1d3fe0b720ad78399284a3645d0bb6dc15b0d (diff)
improve exception handling
Push it down from needing to be done in every Storer, to being checked once inside ChunkedEncryptable. Also, catch exceptions from PrepareStorer and PrepareRetriever, just in case..
Diffstat (limited to 'Remote/Helper/Chunked.hs')
-rw-r--r--Remote/Helper/Chunked.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/Remote/Helper/Chunked.hs b/Remote/Helper/Chunked.hs
index 5fa6c55ef..3eab0947a 100644
--- a/Remote/Helper/Chunked.hs
+++ b/Remote/Helper/Chunked.hs
@@ -70,12 +70,16 @@ numChunks = pred . fromJust . keyChunkNum . fst . nextChunkKeyStream
- the storer action, along with a corresponding chunk key and a
- progress meter update callback.
-
- - Note that the storer action is responsible for catching any
- - exceptions it may encounter.
- -
- This action may be called on a chunked key. It will simply store it.
-}
-storeChunks :: UUID -> ChunkConfig -> Key -> FilePath -> MeterUpdate -> (Key -> L.ByteString -> MeterUpdate -> IO Bool) -> Annex Bool
+storeChunks
+ :: UUID
+ -> ChunkConfig
+ -> Key
+ -> FilePath
+ -> MeterUpdate
+ -> (Key -> L.ByteString -> MeterUpdate -> IO Bool)
+ -> Annex Bool
storeChunks u chunkconfig k f p storer = metered (Just p) k $ \meterupdate ->
either (\e -> warning (show e) >> return False) (go meterupdate)
=<< (liftIO $ tryIO $ L.readFile f)
@@ -188,7 +192,7 @@ retrieveChunks
-> Annex Bool
retrieveChunks retriever u chunkconfig encryptor basek basep sink = do
ls <- chunkKeys u chunkconfig basek
- liftIO $ flip catchNonAsync giveup (firstavail ls)
+ liftIO $ firstavail ls `catchNonAsync` giveup
where
giveup e = do
warningIO (show e)