annex.startupscan can be set to false to disable the assistant's startup scan.

This commit is contained in:
Joey Hess 2014-03-05 17:44:14 -04:00
parent 7dab73db84
commit a3fe8270ca
11 changed files with 46 additions and 28 deletions

View file

@ -39,7 +39,7 @@ mergeThread = namedThread "Merger" $ do
, modifyHook = changehook , modifyHook = changehook
, errHook = errhook , errHook = errhook
} }
void $ liftIO $ watchDir dir (const False) hooks id void $ liftIO $ watchDir dir (const False) True hooks id
debug ["watching", dir] debug ["watching", dir]
type Handler = FilePath -> Assistant () type Handler = FilePath -> Assistant ()

View file

@ -35,7 +35,7 @@ transferWatcherThread = namedThread "TransferWatcher" $ do
, modifyHook = modifyhook , modifyHook = modifyhook
, errHook = errhook , errHook = errhook
} }
void $ liftIO $ watchDir dir (const False) hooks id void $ liftIO $ watchDir dir (const False) True hooks id
debug ["watching for transfers"] debug ["watching for transfers"]
type Handler = FilePath -> Assistant () type Handler = FilePath -> Assistant ()

View file

@ -50,8 +50,9 @@ upgradeWatcherThread urlrenderer = namedThread "UpgradeWatcher" $ do
let dir = parentDir flagfile let dir = parentDir flagfile
let depth = length (splitPath dir) + 1 let depth = length (splitPath dir) + 1
let nosubdirs f = length (splitPath f) == depth let nosubdirs f = length (splitPath f) == depth
void $ liftIO $ watchDir dir nosubdirs hooks (startup mvar) void $ liftIO $ watchDir dir nosubdirs False hooks (startup mvar)
-- Ignore bogus events generated during the startup scan. -- Ignore bogus events generated during the startup scan.
-- We ask the watcher to not generate them, but just to be safe..
startup mvar scanner = do startup mvar scanner = do
r <- scanner r <- scanner
void $ swapMVar mvar Started void $ swapMVar mvar Started

View file

@ -102,7 +102,8 @@ runWatcher = do
, delDirHook = deldirhook , delDirHook = deldirhook
, errHook = errhook , errHook = errhook
} }
handle <- liftIO $ watchDir "." ignored hooks startup scanevents <- liftAnnex $ annexStartupScan <$> Annex.getGitConfig
handle <- liftIO $ watchDir "." ignored scanevents hooks startup
debug [ "watching", "."] debug [ "watching", "."]
{- Let the DirWatcher thread run until signalled to pause it, {- Let the DirWatcher thread run until signalled to pause it,

View file

@ -51,6 +51,7 @@ data GitConfig = GitConfig
, annexSecureEraseCommand :: Maybe String , annexSecureEraseCommand :: Maybe String
, annexGenMetaData :: Bool , annexGenMetaData :: Bool
, annexListen :: Maybe String , annexListen :: Maybe String
, annexStartupScan :: Bool
, coreSymlinks :: Bool , coreSymlinks :: Bool
, gcryptId :: Maybe String , gcryptId :: Maybe String
} }
@ -85,6 +86,7 @@ extractGitConfig r = GitConfig
, annexSecureEraseCommand = getmaybe (annex "secure-erase-command") , annexSecureEraseCommand = getmaybe (annex "secure-erase-command")
, annexGenMetaData = getbool (annex "genmetadata") False , annexGenMetaData = getbool (annex "genmetadata") False
, annexListen = getmaybe (annex "listen") , annexListen = getmaybe (annex "listen")
, annexStartupScan = getbool (annex "startupscan") True
, coreSymlinks = getbool "core.symlinks" True , coreSymlinks = getbool "core.symlinks" True
, gcryptId = getmaybe "core.gcrypt-id" , gcryptId = getmaybe "core.gcrypt-id"
} }

View file

@ -104,33 +104,33 @@ modifyTracked = undefined
- to shutdown later. -} - to shutdown later. -}
#if WITH_INOTIFY #if WITH_INOTIFY
type DirWatcherHandle = INotify.INotify type DirWatcherHandle = INotify.INotify
watchDir :: FilePath -> Pruner -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle
watchDir dir prune hooks runstartup = do watchDir dir prune scanevents hooks runstartup = do
i <- INotify.initINotify i <- INotify.initINotify
runstartup $ INotify.watchDir i dir prune hooks runstartup $ INotify.watchDir i dir prune scanevents hooks
return i return i
#else #else
#if WITH_KQUEUE #if WITH_KQUEUE
type DirWatcherHandle = ThreadId type DirWatcherHandle = ThreadId
watchDir :: FilePath -> Pruner -> WatchHooks -> (IO Kqueue.Kqueue -> IO Kqueue.Kqueue) -> IO DirWatcherHandle watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO Kqueue.Kqueue -> IO Kqueue.Kqueue) -> IO DirWatcherHandle
watchDir dir prune hooks runstartup = do watchDir dir prune _scanevents hooks runstartup = do
kq <- runstartup $ Kqueue.initKqueue dir prune kq <- runstartup $ Kqueue.initKqueue dir prune
forkIO $ Kqueue.runHooks kq hooks forkIO $ Kqueue.runHooks kq hooks
#else #else
#if WITH_FSEVENTS #if WITH_FSEVENTS
type DirWatcherHandle = FSEvents.EventStream type DirWatcherHandle = FSEvents.EventStream
watchDir :: FilePath -> Pruner -> WatchHooks -> (IO FSEvents.EventStream -> IO FSEvents.EventStream) -> IO DirWatcherHandle watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO FSEvents.EventStream -> IO FSEvents.EventStream) -> IO DirWatcherHandle
watchDir dir prune hooks runstartup = watchDir dir prune scanevents hooks runstartup =
runstartup $ FSEvents.watchDir dir prune hooks runstartup $ FSEvents.watchDir dir prune scanevents hooks
#else #else
#if WITH_WIN32NOTIFY #if WITH_WIN32NOTIFY
type DirWatcherHandle = Win32Notify.WatchManager type DirWatcherHandle = Win32Notify.WatchManager
watchDir :: FilePath -> Pruner -> WatchHooks -> (IO Win32Notify.WatchManager -> IO Win32Notify.WatchManager) -> IO DirWatcherHandle watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO Win32Notify.WatchManager -> IO Win32Notify.WatchManager) -> IO DirWatcherHandle
watchDir dir prune hooks runstartup = watchDir dir prune scanevents hooks runstartup =
runstartup $ Win32Notify.watchDir dir prune hooks runstartup $ Win32Notify.watchDir dir prune scanevents hooks
#else #else
type DirWatcherHandle = () type DirWatcherHandle = ()
watchDir :: FilePath -> Pruner -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle
watchDir = undefined watchDir = undefined
#endif #endif
#endif #endif

View file

@ -14,8 +14,8 @@ import System.OSX.FSEvents
import qualified System.Posix.Files as Files import qualified System.Posix.Files as Files
import Data.Bits ((.&.)) import Data.Bits ((.&.))
watchDir :: FilePath -> (FilePath -> Bool) -> WatchHooks -> IO EventStream watchDir :: FilePath -> (FilePath -> Bool) -> Bool -> WatchHooks -> IO EventStream
watchDir dir ignored hooks = do watchDir dir ignored scanevents hooks = do
unlessM fileLevelEventsSupported $ unlessM fileLevelEventsSupported $
error "Need at least OSX 10.7.0 for file-level FSEvents" error "Need at least OSX 10.7.0 for file-level FSEvents"
scan dir scan dir
@ -79,8 +79,10 @@ watchDir dir ignored hooks = do
Nothing -> noop Nothing -> noop
Just s Just s
| Files.isSymbolicLink s -> | Files.isSymbolicLink s ->
when scanevents $
runhook addSymlinkHook ms runhook addSymlinkHook ms
| Files.isRegularFile s -> | Files.isRegularFile s ->
when scanevents $
runhook addHook ms runhook addHook ms
| otherwise -> | otherwise ->
noop noop

View file

@ -46,8 +46,8 @@ import Control.Exception (throw)
- So this will fail if there are too many subdirectories. The - So this will fail if there are too many subdirectories. The
- errHook is called when this happens. - errHook is called when this happens.
-} -}
watchDir :: INotify -> FilePath -> (FilePath -> Bool) -> WatchHooks -> IO () watchDir :: INotify -> FilePath -> (FilePath -> Bool) -> Bool -> WatchHooks -> IO ()
watchDir i dir ignored hooks watchDir i dir ignored scanevents hooks
| ignored dir = noop | ignored dir = noop
| otherwise = do | otherwise = do
-- Use a lock to make sure events generated during initial -- Use a lock to make sure events generated during initial
@ -61,7 +61,7 @@ watchDir i dir ignored hooks
mapM_ scan =<< filter (not . dirCruft) <$> mapM_ scan =<< filter (not . dirCruft) <$>
getDirectoryContents dir getDirectoryContents dir
where where
recurse d = watchDir i d ignored hooks recurse d = watchDir i d ignored scanevents hooks
-- Select only inotify events required by the enabled -- Select only inotify events required by the enabled
-- hooks, but always include Create so new directories can -- hooks, but always include Create so new directories can
@ -85,8 +85,10 @@ watchDir i dir ignored hooks
| Files.isDirectory s -> | Files.isDirectory s ->
recurse $ indir f recurse $ indir f
| Files.isSymbolicLink s -> | Files.isSymbolicLink s ->
when scanevents $
runhook addSymlinkHook f ms runhook addSymlinkHook f ms
| Files.isRegularFile s -> | Files.isRegularFile s ->
when scanevents $
runhook addHook f ms runhook addHook f ms
| otherwise -> | otherwise ->
noop noop

View file

@ -13,8 +13,8 @@ import Utility.DirWatcher.Types
import System.Win32.Notify import System.Win32.Notify
import qualified Utility.PosixFiles as Files import qualified Utility.PosixFiles as Files
watchDir :: FilePath -> (FilePath -> Bool) -> WatchHooks -> IO WatchManager watchDir :: FilePath -> (FilePath -> Bool) -> Bool -> WatchHooks -> IO WatchManager
watchDir dir ignored hooks = do watchDir dir ignored scanevents hooks = do
scan dir scan dir
wm <- initWatchManager wm <- initWatchManager
void $ watchDirectory wm dir True [Create, Delete, Modify, Move] handle void $ watchDirectory wm dir True [Create, Delete, Modify, Move] handle
@ -52,6 +52,7 @@ watchDir dir ignored hooks = do
Nothing -> noop Nothing -> noop
Just s Just s
| Files.isRegularFile s -> | Files.isRegularFile s ->
when scanevents $
runhook addHook ms runhook addHook ms
| otherwise -> | otherwise ->
noop noop

2
debian/changelog vendored
View file

@ -7,6 +7,8 @@ git-annex (5.20140228) UNRELEASED; urgency=medium
* webapp: No longer supports a port specified after --listen, since * webapp: No longer supports a port specified after --listen, since
it was buggy, and that use case is better supported by setting up HTTPS. it was buggy, and that use case is better supported by setting up HTTPS.
* annex.listen can be configured, instead of using --listen * annex.listen can be configured, instead of using --listen
* annex.startupscan can be set to false to disable the assistant's startup
scan.
* Probe for quvi version at run time. * Probe for quvi version at run time.
* webapp: Filter out from Switch Repository list any * webapp: Filter out from Switch Repository list any
repositories listed in autostart file that don't have a repositories listed in autostart file that don't have a

View file

@ -1380,6 +1380,13 @@ Here are all the supported configuration settings.
Set to false to prevent the git-annex assistant from automatically Set to false to prevent the git-annex assistant from automatically
committing changes to files in the repository. committing changes to files in the repository.
* `annex.startupscan`
Set to false to prevent the git-annex assistant from scanning the
repository for new and changed files on startup. This will prevent it
from noticing changes that were made while it was not running, but can be
a useful performance tweak for a large repository.
* `annex.listen` * `annex.listen`
Configures which address the webapp listens on. The default is localhost. Configures which address the webapp listens on. The default is localhost.