summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-28 16:20:05 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-28 16:20:05 -0400
commit92f57da495b25b4d42ed8e2efa3fc09c89b460b0 (patch)
treee529782e6881295ce5c4e5d978eb966290125815
parentc8fdc4272917bd0c6836d41a2aead6dc78794e39 (diff)
fix fsevents rename handling
For both files and whole directories; also tested on moving whole dirs out of and into the working copy.
-rw-r--r--Utility/FSEvents.hs27
-rw-r--r--doc/design/assistant/inotify.mdwn3
2 files changed, 16 insertions, 14 deletions
diff --git a/Utility/FSEvents.hs b/Utility/FSEvents.hs
index fc5dc0a7a..97431c159 100644
--- a/Utility/FSEvents.hs
+++ b/Utility/FSEvents.hs
@@ -38,23 +38,28 @@ watchDir dir ignored hooks = do
if hasflag eventFlagItemIsDir
then runhook delDirHook Nothing
else runhook delHook Nothing
- {- TODO deal with moving whole directories -}
- when (hasflag eventFlagItemCreated || (hasflag eventFlagItemRenamed && not (hasflag eventFlagItemRemoved))) $ do
- ms <- getstatus $ eventPath evt
- case ms of
- Nothing -> noop
- Just s
- | Files.isSymbolicLink s ->
- runhook addSymlinkHook ms
- | Files.isRegularFile s ->
- runhook addHook ms
- | otherwise -> noop
+ when (hasflag eventFlagItemCreated) $
+ maybe noop handleadd =<< getstatus (eventPath evt)
+ {- When a file or dir is renamed, a rename event is
+ - received for both its old and its new name. -}
+ when (hasflag eventFlagItemRenamed) $
+ if hasflag eventFlagItemIsDir
+ then ifM (doesDirectoryExist $ eventPath evt)
+ ( scan $ eventPath evt
+ , runhook delDirHook Nothing
+ )
+ else maybe (runhook delHook Nothing) handleadd
+ =<< getstatus (eventPath evt)
when (hasflag eventFlagItemModified && not (hasflag eventFlagItemIsDir)) $ do
ms <- getstatus $ eventPath evt
runhook modifyHook ms
where
hasflag f = eventFlags evt .&. f /= 0
runhook h s = maybe noop (\a -> a (eventPath evt) s) (h hooks)
+ handleadd s
+ | Files.isSymbolicLink s = runhook addSymlinkHook $ Just s
+ | Files.isRegularFile s = runhook addHook $ Just s
+ | otherwise = noop
scan d = unless (ignoredPath ignored d) $
mapM_ go =<< dirContentsRecursive d
diff --git a/doc/design/assistant/inotify.mdwn b/doc/design/assistant/inotify.mdwn
index edb6564bf..3caaaa0e8 100644
--- a/doc/design/assistant/inotify.mdwn
+++ b/doc/design/assistant/inotify.mdwn
@@ -15,9 +15,6 @@ available!
See [[bug|bugs/Issue_on_OSX_with_some_system_limits]]. (Does not affect
OSX any longer).
-* The OSX FSEvents code is new and relatively untested. A known problem is
- that it does not handle whole directory renames right.
-
## todo
* Run niced and ioniced? Seems to make sense, this is a background job.