summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-10 02:59:13 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-10 02:59:13 -0400
commit95704212510b525bf4fb3c76fc37043da26cb825 (patch)
treeddd244ba8ee26f24c823d97cf854320b6d1ce9e3
parenta218ce41cfef19f306ca462fb5d57c6647a680e2 (diff)
better message when content is locked
-rw-r--r--Annex/Content.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs
index b111bfabc..f50616af9 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -23,6 +23,7 @@ module Annex.Content (
saveState
) where
+import System.IO.Error (try)
import Control.Exception (bracket_)
import System.Posix.Types
@@ -74,8 +75,10 @@ lockContent key a = do
where
lock Nothing = return Nothing
lock (Just l) = do
- setLock l (WriteLock, AbsoluteSeek, 0, 0)
- return $ Just l
+ v <- try $ setLock l (WriteLock, AbsoluteSeek, 0, 0)
+ case v of
+ Left _ -> error "content is locked"
+ Right _ -> return $ Just l
unlock Nothing = return ()
unlock (Just l) = closeFd l