summaryrefslogtreecommitdiff
path: root/Annex/Exception.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-28 16:01:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-28 16:43:11 -0400
commitb037f324aa531201a8ef6d1b4dc56efed622a12e (patch)
treeb0ad70c3772c4663048f044062e8e0cd5d4d8238 /Annex/Exception.hs
parentbbbc725c45f0b25c8da92d002a0ca3ffd2b8efdc (diff)
rework annexed object locking in direct mode & support Windows
Seems that locking of annexed objects when they're being dropped was broken in direct mode: * When taking the lock before dropping, it created the .git/annex/objects file, as an empty file. It seems that the dropping code deleted that, but that is not right, and for all I know could in some situation cause a corrupted object to leak out. * When the lock was checked, it actually tried to open each direct mode file, and checked if it was locked. Not the same lock used above, and could also fail if some consumer of the file locked it. Fixed this, and added windows support by switching direct mode to lock a .lck file.
Diffstat (limited to 'Annex/Exception.hs')
-rw-r--r--Annex/Exception.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/Annex/Exception.hs b/Annex/Exception.hs
index 91347583e..11613d51b 100644
--- a/Annex/Exception.hs
+++ b/Annex/Exception.hs
@@ -14,6 +14,7 @@
module Annex.Exception (
bracketIO,
+ bracketAnnex,
tryAnnex,
tryAnnexIO,
throwAnnex,
@@ -29,6 +30,9 @@ import Common.Annex
bracketIO :: IO v -> (v -> IO b) -> (v -> Annex a) -> Annex a
bracketIO setup cleanup = M.bracket (liftIO setup) (liftIO . cleanup)
+bracketAnnex :: Annex v -> (v -> Annex b) -> (v -> Annex a) -> Annex a
+bracketAnnex = M.bracket
+
{- try in the Annex monad -}
tryAnnex :: Annex a -> Annex (Either SomeException a)
tryAnnex = M.try