better message when content is locked
This commit is contained in:
parent
a218ce41cf
commit
9570421251
1 changed files with 5 additions and 2 deletions
|
@ -23,6 +23,7 @@ module Annex.Content (
|
||||||
saveState
|
saveState
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import System.IO.Error (try)
|
||||||
import Control.Exception (bracket_)
|
import Control.Exception (bracket_)
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
|
|
||||||
|
@ -74,8 +75,10 @@ lockContent key a = do
|
||||||
where
|
where
|
||||||
lock Nothing = return Nothing
|
lock Nothing = return Nothing
|
||||||
lock (Just l) = do
|
lock (Just l) = do
|
||||||
setLock l (WriteLock, AbsoluteSeek, 0, 0)
|
v <- try $ setLock l (WriteLock, AbsoluteSeek, 0, 0)
|
||||||
return $ Just l
|
case v of
|
||||||
|
Left _ -> error "content is locked"
|
||||||
|
Right _ -> return $ Just l
|
||||||
unlock Nothing = return ()
|
unlock Nothing = return ()
|
||||||
unlock (Just l) = closeFd l
|
unlock (Just l) = closeFd l
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue