assistant: More robust inotify handling; avoid crashing if a directory cannot be read.
This commit is contained in:
parent
87c7f5dd62
commit
6b37fcffd8
3 changed files with 16 additions and 6 deletions
|
@ -54,11 +54,12 @@ watchDir i dir ignored hooks
|
||||||
-- scan come before real inotify events.
|
-- scan come before real inotify events.
|
||||||
lock <- newLock
|
lock <- newLock
|
||||||
let handler event = withLock lock (void $ go event)
|
let handler event = withLock lock (void $ go event)
|
||||||
void (addWatch i watchevents dir handler)
|
flip catchNonAsync failedwatch $ do
|
||||||
`catchIO` failedaddwatch
|
void (addWatch i watchevents dir handler)
|
||||||
withLock lock $
|
`catchIO` failedaddwatch
|
||||||
mapM_ scan =<< filter (not . dirCruft) <$>
|
withLock lock $
|
||||||
getDirectoryContents dir
|
mapM_ scan =<< filter (not . dirCruft) <$>
|
||||||
|
getDirectoryContents dir
|
||||||
where
|
where
|
||||||
recurse d = watchDir i d ignored hooks
|
recurse d = watchDir i d ignored hooks
|
||||||
|
|
||||||
|
@ -149,12 +150,14 @@ watchDir i dir ignored hooks
|
||||||
-- disk full error.
|
-- disk full error.
|
||||||
| isFullError e =
|
| isFullError e =
|
||||||
case errHook hooks of
|
case errHook hooks of
|
||||||
Nothing -> throw e
|
Nothing -> error $ "failed to add inotify watch on directory " ++ dir ++ " (" ++ show e ++ ")"
|
||||||
Just hook -> tooManyWatches hook dir
|
Just hook -> tooManyWatches hook dir
|
||||||
-- The directory could have been deleted.
|
-- The directory could have been deleted.
|
||||||
| isDoesNotExistError e = return ()
|
| isDoesNotExistError e = return ()
|
||||||
| otherwise = throw e
|
| otherwise = throw e
|
||||||
|
|
||||||
|
failedwatch e = hPutStrLn stderr $ "failed to add watch on directory " ++ dir ++ " (" ++ show e ++ ")"
|
||||||
|
|
||||||
tooManyWatches :: (String -> Maybe FileStatus -> IO ()) -> FilePath -> IO ()
|
tooManyWatches :: (String -> Maybe FileStatus -> IO ()) -> FilePath -> IO ()
|
||||||
tooManyWatches hook dir = do
|
tooManyWatches hook dir = do
|
||||||
sysctlval <- querySysctl [Param maxwatches] :: IO (Maybe Integer)
|
sysctlval <- querySysctl [Param maxwatches] :: IO (Maybe Integer)
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -26,6 +26,8 @@ git-annex (4.20130921) UNRELEASED; urgency=low
|
||||||
yet knowing about the new remote.
|
yet knowing about the new remote.
|
||||||
* OSX: Bundled gpg upgraded, now compatible with config files
|
* OSX: Bundled gpg upgraded, now compatible with config files
|
||||||
written by MacGPG.
|
written by MacGPG.
|
||||||
|
* assistant: More robust inotify handling; avoid crashing if a directory
|
||||||
|
cannot be read.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sun, 22 Sep 2013 19:42:29 -0400
|
-- Joey Hess <joeyh@debian.org> Sun, 22 Sep 2013 19:42:29 -0400
|
||||||
|
|
||||||
|
|
|
@ -1 +1,6 @@
|
||||||
When addWatcher gets a permission denied, it would be helpful to display the name of the object on which the permission was denied, in the error message which shows in the webapp.
|
When addWatcher gets a permission denied, it would be helpful to display the name of the object on which the permission was denied, in the error message which shows in the webapp.
|
||||||
|
|
||||||
|
> I have made the inotify code more robust; now it doesn't crash if it
|
||||||
|
> cannot read a directory or a file, and only logs a warning, which includes
|
||||||
|
> the directory name.
|
||||||
|
> [[done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue