diff options
author | Joey Hess <joey@kitenet.net> | 2013-04-24 17:46:46 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-04-24 17:46:46 -0400 |
commit | 5ac5539703cf6e9ffea31b2f2bba3c4fe4862569 (patch) | |
tree | 11069098f0f74e3d7e4e077d2d8f856774cdcdd0 /Assistant/Threads | |
parent | d265917659b09e30d7ad0db345621b9b06288274 (diff) |
refactoring and minor performance tweak
Diffstat (limited to 'Assistant/Threads')
-rw-r--r-- | Assistant/Threads/Watcher.hs | 17 |
1 files changed, 9 insertions, 8 deletions
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 |