diff options
author | Joey Hess <joey@kitenet.net> | 2012-06-04 14:46:09 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-06-04 14:54:14 -0400 |
commit | 47f8f43715f355e141fc2d57ce7f72bdda75b5d6 (patch) | |
tree | 4dc63444ce4ae7df79d014683c0aa2010c56b7cd /Utility | |
parent | fa9d479fd1102efeebaafca66d7747bf07604ecb (diff) |
workaround other part of moved directory problem
This fixes the scenario where:
* directory foo is moved away (and still watched)
* a new directory foo is made
* file (or directory) foo/bar is created
* the old directory's file (or directory) "bar" is deleted
We don't want a deletion event for foo/bar in this case.
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Inotify.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Utility/Inotify.hs b/Utility/Inotify.hs index c5caf0655..320f45525 100644 --- a/Utility/Inotify.hs +++ b/Utility/Inotify.hs @@ -98,16 +98,25 @@ watchDir i dir ignored add addsymlink del deldir go (MovedIn { filePath = f }) = walk f go (MovedOut { isDirectory = True, filePath = d }) = deldir <@> d go (MovedOut { filePath = f }) = del <@> f - go (Deleted { isDirectory = True, filePath = d }) = deldir <@> d - go (Deleted { filePath = f }) = del <@> f + go (Deleted { isDirectory = True, filePath = d }) = + notexist d $ deldir <@> d + go (Deleted { filePath = f }) = + notexist f $ del <@> f go _ = noop Just a <@> f = a $ indir f Nothing <@> _ = noop indir f = dir </> f + filetype t f = catchBoolIO $ t <$> getSymbolicLinkStatus (indir f) + -- Check that a file or directory does not exist. + -- This is used when there could be a spurious deletion + -- event for an item in a directory that has been moved away + -- but is still being watched. + notexist f = unlessM (filetype (const True) f) + {- Pauses the main thread, letting children run until program termination. -} waitForTermination :: IO () waitForTermination = do |