summaryrefslogtreecommitdiff
path: root/Branch.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-10-04 00:34:04 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-10-04 00:34:04 -0400
commitff21fd4a652cc6516d0e06ab885adf1c93eddced (patch)
treea84f041317fdbdb07377459e725e165e0845b8c0 /Branch.hs
parent1a96d4ab35ed5c2af95a1598620cbbd13bc295b3 (diff)
factor out Annex exception handling module
Diffstat (limited to 'Branch.hs')
-rw-r--r--Branch.hs15
1 files changed, 5 insertions, 10 deletions
diff --git a/Branch.hs b/Branch.hs
index 554f16848..a2ddc70ac 100644
--- a/Branch.hs
+++ b/Branch.hs
@@ -21,10 +21,9 @@ module Branch (
import System.IO.Binary
import System.Exit
import qualified Data.ByteString.Lazy.Char8 as L
-import Control.Monad.IO.Control (liftIOOp)
-import qualified Control.Exception
import AnnexCommon
+import Annex.Exception
import Types.BranchState
import qualified Git
import qualified Git.UnionMerge
@@ -66,7 +65,7 @@ withIndex' bootstrapping a = do
g <- gitRepo
let f = index g
- bracket (Git.useIndex f) id $ do
+ bracketIO (Git.useIndex f) id $ do
unlessM (liftIO $ doesFileExist f) $ do
unless bootstrapping create
liftIO $ createDirectoryIfMissing True $ takeDirectory f
@@ -93,9 +92,9 @@ invalidateCache = do
setState state { cachedFile = Nothing, cachedContent = "" }
getCache :: FilePath -> Annex (Maybe String)
-getCache file = getState >>= handle
+getCache file = getState >>= go
where
- handle state
+ go state
| cachedFile state == Just file =
return $ Just $ cachedContent state
| otherwise = return Nothing
@@ -328,14 +327,10 @@ lockJournal :: Annex a -> Annex a
lockJournal a = do
g <- gitRepo
let file = gitAnnexJournalLock g
- bracket (lock file) unlock a
+ bracketIO (lock file) unlock a
where
lock file = do
l <- createFile file stdFileMode
waitToSetLock l (WriteLock, AbsoluteSeek, 0, 0)
return l
unlock = closeFd
-
-bracket :: IO c -> (c -> IO b) -> Annex a -> Annex a
-bracket start cleanup go =
- liftIOOp (Control.Exception.bracket start cleanup) (const go)