summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Changes.hs3
-rw-r--r--Assistant/Threads/Watcher.hs17
2 files changed, 12 insertions, 8 deletions
diff --git a/Assistant/Changes.hs b/Assistant/Changes.hs
index 0a93d6335..9daef511b 100644
--- a/Assistant/Changes.hs
+++ b/Assistant/Changes.hs
@@ -42,3 +42,6 @@ refillChanges cs = (atomically . flip appendTList cs) <<~ changePool
{- Records a change to the pool. -}
recordChange :: Change -> Assistant ()
recordChange c = (atomically . flip snocTList c) <<~ changePool
+
+recordChanges :: [Change] -> Assistant ()
+recordChanges = refillChanges
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index 2ee3fb5f7..4201a6404 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -130,8 +130,7 @@ startupScan scanner = do
top <- liftAnnex $ fromRepo Git.repoPath
(fs, cleanup) <- liftAnnex $ inRepo $ LsFiles.deleted [top]
forM_ fs $ \f -> do
- liftAnnex $ Annex.Queue.addUpdateIndex =<<
- inRepo (Git.UpdateIndex.unstageFile f)
+ liftAnnex $ onDel' f
maybe noop recordChange =<< madeChange f RmChange
void $ liftIO $ cleanup
@@ -296,11 +295,14 @@ addLink file link mk = do
onDel :: Handler
onDel file _ = do
debug ["file deleted", file]
- liftAnnex $
- Annex.Queue.addUpdateIndex =<<
- inRepo (Git.UpdateIndex.unstageFile file)
+ liftAnnex $ onDel' file
madeChange file RmChange
+onDel' :: FilePath -> Annex ()
+onDel' file = do
+ Annex.Queue.addUpdateIndex =<<
+ inRepo (Git.UpdateIndex.unstageFile file)
+
{- A directory has been deleted, or moved, so tell git to remove anything
- that was inside it from its cache. Since it could reappear at any time,
- use --cached to only delete it from the index.
@@ -312,13 +314,12 @@ onDelDir dir _ = do
debug ["directory deleted", dir]
(fs, clean) <- liftAnnex $ inRepo $ LsFiles.deleted [dir]
- liftAnnex $ forM_ fs $ \f -> Annex.Queue.addUpdateIndex =<<
- inRepo (Git.UpdateIndex.unstageFile f)
+ liftAnnex $ mapM_ onDel' fs
-- Get the events queued up as fast as possible, so the
-- committer sees them all in one block.
now <- liftIO getCurrentTime
- forM_ fs $ \f -> recordChange $ Change now f RmChange
+ recordChanges $ map (\f -> Change now f RmChange) fs
void $ liftIO $ clean
liftAnnex $ Annex.Queue.flushWhenFull