init: Catch more exceptions when testing locking.

This commit is contained in:
Joey Hess 2019-08-29 12:19:07 -04:00
parent dc19fa8b04
commit d6e1f09ed2
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 22 additions and 3 deletions

View file

@ -51,6 +51,7 @@ import qualified Utility.LockFile.Posix as Posix
#endif
import qualified Data.Map as M
import Data.Either
checkCanInitialize :: Annex a -> Annex a
checkCanInitialize a = inRepo (noAnnexFileContent . Git.repoWorkTree) >>= \case
@ -233,9 +234,10 @@ probeLockSupport = do
mode <- annexFileMode
liftIO $ do
nukeFile f
ok <- catchBoolIO $ do
Posix.dropLock =<< Posix.lockExclusive (Just mode) f
return True
let locktest =
Posix.lockExclusive (Just mode) f
>>= Posix.dropLock
ok <- isRight <$> tryNonAsync locktest
nukeFile f
return ok
#endif