refactoring and minor performance tweak
This commit is contained in:
parent
7fa2d255da
commit
b8e45ec9d7
2 changed files with 12 additions and 8 deletions
|
@ -42,3 +42,6 @@ refillChanges cs = (atomically . flip appendTList cs) <<~ changePool
|
||||||
{- Records a change to the pool. -}
|
{- Records a change to the pool. -}
|
||||||
recordChange :: Change -> Assistant ()
|
recordChange :: Change -> Assistant ()
|
||||||
recordChange c = (atomically . flip snocTList c) <<~ changePool
|
recordChange c = (atomically . flip snocTList c) <<~ changePool
|
||||||
|
|
||||||
|
recordChanges :: [Change] -> Assistant ()
|
||||||
|
recordChanges = refillChanges
|
||||||
|
|
|
@ -130,8 +130,7 @@ startupScan scanner = do
|
||||||
top <- liftAnnex $ fromRepo Git.repoPath
|
top <- liftAnnex $ fromRepo Git.repoPath
|
||||||
(fs, cleanup) <- liftAnnex $ inRepo $ LsFiles.deleted [top]
|
(fs, cleanup) <- liftAnnex $ inRepo $ LsFiles.deleted [top]
|
||||||
forM_ fs $ \f -> do
|
forM_ fs $ \f -> do
|
||||||
liftAnnex $ Annex.Queue.addUpdateIndex =<<
|
liftAnnex $ onDel' f
|
||||||
inRepo (Git.UpdateIndex.unstageFile f)
|
|
||||||
maybe noop recordChange =<< madeChange f RmChange
|
maybe noop recordChange =<< madeChange f RmChange
|
||||||
void $ liftIO $ cleanup
|
void $ liftIO $ cleanup
|
||||||
|
|
||||||
|
@ -296,11 +295,14 @@ addLink file link mk = do
|
||||||
onDel :: Handler
|
onDel :: Handler
|
||||||
onDel file _ = do
|
onDel file _ = do
|
||||||
debug ["file deleted", file]
|
debug ["file deleted", file]
|
||||||
liftAnnex $
|
liftAnnex $ onDel' file
|
||||||
Annex.Queue.addUpdateIndex =<<
|
|
||||||
inRepo (Git.UpdateIndex.unstageFile file)
|
|
||||||
madeChange file RmChange
|
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
|
{- 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,
|
- that was inside it from its cache. Since it could reappear at any time,
|
||||||
- use --cached to only delete it from the index.
|
- use --cached to only delete it from the index.
|
||||||
|
@ -312,13 +314,12 @@ onDelDir dir _ = do
|
||||||
debug ["directory deleted", dir]
|
debug ["directory deleted", dir]
|
||||||
(fs, clean) <- liftAnnex $ inRepo $ LsFiles.deleted [dir]
|
(fs, clean) <- liftAnnex $ inRepo $ LsFiles.deleted [dir]
|
||||||
|
|
||||||
liftAnnex $ forM_ fs $ \f -> Annex.Queue.addUpdateIndex =<<
|
liftAnnex $ mapM_ onDel' fs
|
||||||
inRepo (Git.UpdateIndex.unstageFile f)
|
|
||||||
|
|
||||||
-- Get the events queued up as fast as possible, so the
|
-- Get the events queued up as fast as possible, so the
|
||||||
-- committer sees them all in one block.
|
-- committer sees them all in one block.
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
forM_ fs $ \f -> recordChange $ Change now f RmChange
|
recordChanges $ map (\f -> Change now f RmChange) fs
|
||||||
|
|
||||||
void $ liftIO $ clean
|
void $ liftIO $ clean
|
||||||
liftAnnex $ Annex.Queue.flushWhenFull
|
liftAnnex $ Annex.Queue.flushWhenFull
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue