From 65962bdc503a084bf17a488e1a5e03c41fb29b2a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 22 May 2013 20:58:27 -0400 Subject: improve robustness of fromDirect and replaceFile Made fromDirect check that a file in the tree has good content (and is not a broken symlink either) before copying it to another file that has the same key. Made replaceFile clean up the temp file if the action that creates it, or the file replacement action fails. --- Annex/Exception.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Annex/Exception.hs') diff --git a/Annex/Exception.hs b/Annex/Exception.hs index f06f568a4..96070ee26 100644 --- a/Annex/Exception.hs +++ b/Annex/Exception.hs @@ -24,9 +24,8 @@ import Control.Exception hiding (handle, try, throw, bracket, catch) import Common.Annex {- Runs an Annex action, with setup and cleanup both in the IO monad. -} -bracketIO :: IO c -> (c -> IO b) -> Annex a -> Annex a -bracketIO setup cleanup go = - bracket (liftIO setup) (liftIO . cleanup) (const go) +bracketIO :: IO v -> (v -> IO b) -> (v -> Annex a) -> Annex a +bracketIO setup cleanup go = bracket (liftIO setup) (liftIO . cleanup) go {- try in the Annex monad -} tryAnnex :: Annex a -> Annex (Either SomeException a) -- cgit v1.2.3