catch more exceptions

I saw this:

  .git/annex/tmp/SHA256E-s1234376--5ba8e06e0163b217663907482bbed57684d7188024155ddc81da0710dfd2687d: openBinaryFile: resource busy (file is locked)

 guess catching IO exceptions did not catch that one.
This commit is contained in:
Joey Hess 2021-08-13 16:16:46 -04:00
parent dadbb510f6
commit 16dd3dd4ca
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -166,19 +166,19 @@ startVerifyKeyContentIncrementally verifyconfig k =
tailVerify :: IncrementalVerifier -> RawFilePath -> TMVar () -> IO (Maybe (IO ())) tailVerify :: IncrementalVerifier -> RawFilePath -> TMVar () -> IO (Maybe (IO ()))
#if WITH_INOTIFY #if WITH_INOTIFY
tailVerify iv f finished = tailVerify iv f finished =
tryIO go >>= \case tryNonAsync go >>= \case
Right r -> return r Right r -> return r
Left _ -> do Left _ -> do
failIncremental iv failIncremental iv
return Nothing return Nothing
where where
f' = fromRawFilePath f f' = fromRawFilePath f
waitforfiletoexist i = tryIO (openBinaryFile f' ReadMode) >>= \case waitforfiletoexist i = tryNonAsync (openBinaryFile f' ReadMode) >>= \case
Right h -> return (Just h) Right h -> return (Just h)
Left _ -> do Left _ -> do
hv <- newEmptyTMVarIO hv <- newEmptyTMVarIO
wd <- inotifycreate i $ wd <- inotifycreate i $
tryIO (openBinaryFile f' ReadMode) >>= \case tryNonAsync (openBinaryFile f' ReadMode) >>= \case
Right h -> Right h ->
unlessM (atomically $ tryPutTMVar hv h) $ unlessM (atomically $ tryPutTMVar hv h) $
hClose h hClose h
@ -219,7 +219,7 @@ tailVerify iv f finished =
go = INotify.withINotify $ \i -> do go = INotify.withINotify $ \i -> do
h <- waitforfiletoexist i h <- waitforfiletoexist i
tryIO (go' i h) >>= \case tryNonAsync (go' i h) >>= \case
Right r -> return r Right r -> return r
Left _ -> do Left _ -> do
maybe noop hClose h maybe noop hClose h
@ -274,7 +274,7 @@ tailVerify iv f finished =
now <- getPOSIXTime now <- getPOSIXTime
if now - starttime > 0.5 if now - starttime > 0.5
then return $ Just $ then return $ Just $
tryIO (deferredfinish h) >>= \case tryNonAsync (deferredfinish h) >>= \case
Right () -> noop Right () -> noop
Left _ -> failIncremental iv Left _ -> failIncremental iv
else finish h starttime else finish h starttime