summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assistant/Threads/Merger.hs2
-rw-r--r--Assistant/Threads/TransferWatcher.hs2
-rw-r--r--Assistant/Threads/UpgradeWatcher.hs3
-rw-r--r--Assistant/Threads/Watcher.hs3
-rw-r--r--Types/GitConfig.hs2
-rw-r--r--Utility/DirWatcher.hs24
-rw-r--r--Utility/DirWatcher/FSEvents.hs10
-rw-r--r--Utility/DirWatcher/INotify.hs12
-rw-r--r--Utility/DirWatcher/Win32Notify.hs7
-rw-r--r--debian/changelog2
-rw-r--r--doc/git-annex.mdwn7
11 files changed, 46 insertions, 28 deletions
diff --git a/Assistant/Threads/Merger.hs b/Assistant/Threads/Merger.hs
index 12489b590..03bcf0aad 100644
--- a/Assistant/Threads/Merger.hs
+++ b/Assistant/Threads/Merger.hs
@@ -39,7 +39,7 @@ mergeThread = namedThread "Merger" $ do
, modifyHook = changehook
, errHook = errhook
}
- void $ liftIO $ watchDir dir (const False) hooks id
+ void $ liftIO $ watchDir dir (const False) True hooks id
debug ["watching", dir]
type Handler = FilePath -> Assistant ()
diff --git a/Assistant/Threads/TransferWatcher.hs b/Assistant/Threads/TransferWatcher.hs
index cd7282865..6e8791732 100644
--- a/Assistant/Threads/TransferWatcher.hs
+++ b/Assistant/Threads/TransferWatcher.hs
@@ -35,7 +35,7 @@ transferWatcherThread = namedThread "TransferWatcher" $ do
, modifyHook = modifyhook
, errHook = errhook
}
- void $ liftIO $ watchDir dir (const False) hooks id
+ void $ liftIO $ watchDir dir (const False) True hooks id
debug ["watching for transfers"]
type Handler = FilePath -> Assistant ()
diff --git a/Assistant/Threads/UpgradeWatcher.hs b/Assistant/Threads/UpgradeWatcher.hs
index 80f2040a0..ffad09d3d 100644
--- a/Assistant/Threads/UpgradeWatcher.hs
+++ b/Assistant/Threads/UpgradeWatcher.hs
@@ -50,8 +50,9 @@ upgradeWatcherThread urlrenderer = namedThread "UpgradeWatcher" $ do
let dir = parentDir flagfile
let depth = length (splitPath dir) + 1
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.
+ -- We ask the watcher to not generate them, but just to be safe..
startup mvar scanner = do
r <- scanner
void $ swapMVar mvar Started
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index 611eca1a7..8a8e8faf0 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -102,7 +102,8 @@ runWatcher = do
, delDirHook = deldirhook
, errHook = errhook
}
- handle <- liftIO $ watchDir "." ignored hooks startup
+ scanevents <- liftAnnex $ annexStartupScan <$> Annex.getGitConfig
+ handle <- liftIO $ watchDir "." ignored scanevents hooks startup
debug [ "watching", "."]
{- Let the DirWatcher thread run until signalled to pause it,
diff --git a/Types/GitConfig.hs b/Types/GitConfig.hs
index ddcf6da50..b49f3d762 100644
--- a/Types/GitConfig.hs
+++ b/Types/GitConfig.hs
@@ -51,6 +51,7 @@ data GitConfig = GitConfig
, annexSecureEraseCommand :: Maybe String
, annexGenMetaData :: Bool
, annexListen :: Maybe String
+ , annexStartupScan :: Bool
, coreSymlinks :: Bool
, gcryptId :: Maybe String
}
@@ -85,6 +86,7 @@ extractGitConfig r = GitConfig
, annexSecureEraseCommand = getmaybe (annex "secure-erase-command")
, annexGenMetaData = getbool (annex "genmetadata") False
, annexListen = getmaybe (annex "listen")
+ , annexStartupScan = getbool (annex "startupscan") True
, coreSymlinks = getbool "core.symlinks" True
, gcryptId = getmaybe "core.gcrypt-id"
}
diff --git a/Utility/DirWatcher.hs b/Utility/DirWatcher.hs
index 9eeddce3d..077410575 100644
--- a/Utility/DirWatcher.hs
+++ b/Utility/DirWatcher.hs
@@ -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
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
diff --git a/debian/changelog b/debian/changelog
index cefa45e89..e3fa18572 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,8 @@ git-annex (5.20140228) UNRELEASED; urgency=medium
* webapp: No longer supports a port specified after --listen, since
it was buggy, and that use case is better supported by setting up HTTPS.
* 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.
* webapp: Filter out from Switch Repository list any
repositories listed in autostart file that don't have a
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 53b9c2eab..30494e95c 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -1380,6 +1380,13 @@ Here are all the supported configuration settings.
Set to false to prevent the git-annex assistant from automatically
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`
Configures which address the webapp listens on. The default is localhost.