From 1db1469905cd08da2b4a2f5e310437ff5233f286 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Mar 2014 17:44:14 -0400 Subject: annex.startupscan can be set to false to disable the assistant's startup scan. --- Utility/DirWatcher/FSEvents.hs | 10 ++++++---- Utility/DirWatcher/INotify.hs | 12 +++++++----- Utility/DirWatcher/Win32Notify.hs | 7 ++++--- 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'Utility/DirWatcher') diff --git a/Utility/DirWatcher/FSEvents.hs b/Utility/DirWatcher/FSEvents.hs index db6ac0434..26e1f7671 100644 --- a/Utility/DirWatcher/FSEvents.hs +++ b/Utility/DirWatcher/FSEvents.hs @@ -14,8 +14,8 @@ import System.OSX.FSEvents import qualified System.Posix.Files as Files import Data.Bits ((.&.)) -watchDir :: FilePath -> (FilePath -> Bool) -> WatchHooks -> IO EventStream -watchDir dir ignored hooks = do +watchDir :: FilePath -> (FilePath -> Bool) -> Bool -> WatchHooks -> IO EventStream +watchDir dir ignored scanevents hooks = do unlessM fileLevelEventsSupported $ error "Need at least OSX 10.7.0 for file-level FSEvents" scan dir @@ -79,9 +79,11 @@ watchDir dir ignored hooks = do Nothing -> noop Just s | Files.isSymbolicLink s -> - runhook addSymlinkHook ms + when scanevents $ + runhook addSymlinkHook ms | Files.isRegularFile s -> - runhook addHook ms + when scanevents $ + runhook addHook ms | otherwise -> noop where diff --git a/Utility/DirWatcher/INotify.hs b/Utility/DirWatcher/INotify.hs index 922f202a4..016858b1b 100644 --- a/Utility/DirWatcher/INotify.hs +++ b/Utility/DirWatcher/INotify.hs @@ -46,8 +46,8 @@ import Control.Exception (throw) - So this will fail if there are too many subdirectories. The - errHook is called when this happens. -} -watchDir :: INotify -> FilePath -> (FilePath -> Bool) -> WatchHooks -> IO () -watchDir i dir ignored hooks +watchDir :: INotify -> FilePath -> (FilePath -> Bool) -> Bool -> WatchHooks -> IO () +watchDir i dir ignored scanevents hooks | ignored dir = noop | otherwise = do -- Use a lock to make sure events generated during initial @@ -61,7 +61,7 @@ watchDir i dir ignored hooks mapM_ scan =<< filter (not . dirCruft) <$> getDirectoryContents dir where - recurse d = watchDir i d ignored hooks + recurse d = watchDir i d ignored scanevents hooks -- Select only inotify events required by the enabled -- hooks, but always include Create so new directories can @@ -85,9 +85,11 @@ watchDir i dir ignored hooks | Files.isDirectory s -> recurse $ indir f | Files.isSymbolicLink s -> - runhook addSymlinkHook f ms + when scanevents $ + runhook addSymlinkHook f ms | Files.isRegularFile s -> - runhook addHook f ms + when scanevents $ + runhook addHook f ms | otherwise -> noop diff --git a/Utility/DirWatcher/Win32Notify.hs b/Utility/DirWatcher/Win32Notify.hs index ba786839c..f095e5d0e 100644 --- a/Utility/DirWatcher/Win32Notify.hs +++ b/Utility/DirWatcher/Win32Notify.hs @@ -13,8 +13,8 @@ import Utility.DirWatcher.Types import System.Win32.Notify import qualified Utility.PosixFiles as Files -watchDir :: FilePath -> (FilePath -> Bool) -> WatchHooks -> IO WatchManager -watchDir dir ignored hooks = do +watchDir :: FilePath -> (FilePath -> Bool) -> Bool -> WatchHooks -> IO WatchManager +watchDir dir ignored scanevents hooks = do scan dir wm <- initWatchManager void $ watchDirectory wm dir True [Create, Delete, Modify, Move] handle @@ -52,7 +52,8 @@ watchDir dir ignored hooks = do Nothing -> noop Just s | Files.isRegularFile s -> - runhook addHook ms + when scanevents $ + runhook addHook ms | otherwise -> noop where -- cgit v1.2.3