annex.startupscan can be set to false to disable the assistant's startup scan.
This commit is contained in:
parent
7dab73db84
commit
a3fe8270ca
11 changed files with 46 additions and 28 deletions
|
@ -104,33 +104,33 @@ modifyTracked = undefined
|
|||
- to shutdown later. -}
|
||||
#if WITH_INOTIFY
|
||||
type DirWatcherHandle = INotify.INotify
|
||||
watchDir :: FilePath -> Pruner -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle
|
||||
watchDir dir prune hooks runstartup = do
|
||||
watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle
|
||||
watchDir dir prune scanevents hooks runstartup = do
|
||||
i <- INotify.initINotify
|
||||
runstartup $ INotify.watchDir i dir prune hooks
|
||||
runstartup $ INotify.watchDir i dir prune scanevents hooks
|
||||
return i
|
||||
#else
|
||||
#if WITH_KQUEUE
|
||||
type DirWatcherHandle = ThreadId
|
||||
watchDir :: FilePath -> Pruner -> WatchHooks -> (IO Kqueue.Kqueue -> IO Kqueue.Kqueue) -> IO DirWatcherHandle
|
||||
watchDir dir prune hooks runstartup = do
|
||||
watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO Kqueue.Kqueue -> IO Kqueue.Kqueue) -> IO DirWatcherHandle
|
||||
watchDir dir prune _scanevents hooks runstartup = do
|
||||
kq <- runstartup $ Kqueue.initKqueue dir prune
|
||||
forkIO $ Kqueue.runHooks kq hooks
|
||||
#else
|
||||
#if WITH_FSEVENTS
|
||||
type DirWatcherHandle = FSEvents.EventStream
|
||||
watchDir :: FilePath -> Pruner -> WatchHooks -> (IO FSEvents.EventStream -> IO FSEvents.EventStream) -> IO DirWatcherHandle
|
||||
watchDir dir prune hooks runstartup =
|
||||
runstartup $ FSEvents.watchDir dir prune hooks
|
||||
watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO FSEvents.EventStream -> IO FSEvents.EventStream) -> IO DirWatcherHandle
|
||||
watchDir dir prune scanevents hooks runstartup =
|
||||
runstartup $ FSEvents.watchDir dir prune scanevents hooks
|
||||
#else
|
||||
#if WITH_WIN32NOTIFY
|
||||
type DirWatcherHandle = Win32Notify.WatchManager
|
||||
watchDir :: FilePath -> Pruner -> WatchHooks -> (IO Win32Notify.WatchManager -> IO Win32Notify.WatchManager) -> IO DirWatcherHandle
|
||||
watchDir dir prune hooks runstartup =
|
||||
runstartup $ Win32Notify.watchDir dir prune hooks
|
||||
watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO Win32Notify.WatchManager -> IO Win32Notify.WatchManager) -> IO DirWatcherHandle
|
||||
watchDir dir prune scanevents hooks runstartup =
|
||||
runstartup $ Win32Notify.watchDir dir prune scanevents hooks
|
||||
#else
|
||||
type DirWatcherHandle = ()
|
||||
watchDir :: FilePath -> Pruner -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle
|
||||
watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle
|
||||
watchDir = undefined
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue