diff options
author | Joey Hess <joey@kitenet.net> | 2012-06-10 19:08:03 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-06-10 19:10:18 -0400 |
commit | c1b432ee54424c3943dee97ff2dd90c4cc533e9b (patch) | |
tree | 77b709f75819e795ed8cf71d6c48940fa3189c48 /Command | |
parent | aae0ba1995e258c4f4b83b40eb6324ec1f9baa05 (diff) |
run git add --update after inotify is started
This way, there's no window where deleted files won't be noticed.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Watch.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Command/Watch.hs b/Command/Watch.hs index ab0c0ce79..c57b21ac6 100644 --- a/Command/Watch.hs +++ b/Command/Watch.hs @@ -57,10 +57,8 @@ watch :: Annex () #if defined linux_HOST_OS watch = do showAction "scanning" - inRepo $ Git.Command.run "add" [Param "--update"] withStateMVar $ \st -> liftIO $ withINotify $ \i -> do changechan <- atomically newTChan - _ <- forkIO $ commitThread st changechan let hook a = Just $ runHandler st changechan a let hooks = WatchHooks { addHook = hook onAdd @@ -69,7 +67,17 @@ watch = do , delDirHook = hook onDelDir , errHook = hook onErr } + -- The commit thread is started early, so that the user + -- can immediately begin adding files and having them + -- committed, even while the inotify scan is taking place. + _ <- forkIO $ commitThread st changechan + -- This does not return until the inotify scan is done. + -- That can take some time for large trees. watchDir i "." (ignored . takeFileName) hooks + -- Notice any files that were deleted before inotify + -- was started. + runStateMVar st $ + inRepo $ Git.Command.run "add" [Param "--update"] putStrLn "(started)" waitForTermination #else |