fix memory leak when staging the journal
The list of files had to be retained until the end so it could be deleted. Also, a list of update-index lines was generated and only then fed into it. Now everything streams in constant space.
This commit is contained in:
parent
cdd6cdbb67
commit
7ebd98d8d8
4 changed files with 52 additions and 42 deletions
|
@ -1,6 +1,6 @@
|
|||
{- management of the git-annex branch
|
||||
-
|
||||
- Copyright 2011 Joey Hess <joey@kitenet.net>
|
||||
- Copyright 2011-2012 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -32,7 +32,7 @@ import qualified Git.Command
|
|||
import qualified Git.Ref
|
||||
import qualified Git.Branch
|
||||
import qualified Git.UnionMerge
|
||||
import qualified Git.HashObject
|
||||
import Git.HashObject
|
||||
import qualified Git.Index
|
||||
import Annex.CatFile
|
||||
|
||||
|
@ -307,13 +307,14 @@ stageJournal = do
|
|||
fs <- getJournalFiles
|
||||
g <- gitRepo
|
||||
withIndex $ liftIO $ do
|
||||
let dir = gitAnnexJournalDir g
|
||||
let paths = map (dir </>) fs
|
||||
(shas, cleanup) <- Git.HashObject.hashFiles paths g
|
||||
Git.UnionMerge.update_index g $
|
||||
index_lines shas (map fileJournal fs)
|
||||
cleanup
|
||||
mapM_ removeFile paths
|
||||
h <- hashObjectStart g
|
||||
Git.UnionMerge.stream_update_index g
|
||||
[genstream (gitAnnexJournalDir g) h fs]
|
||||
hashObjectStop h
|
||||
where
|
||||
index_lines shas = map genline . zip shas
|
||||
genline (sha, file) = Git.UnionMerge.update_index_line sha file
|
||||
genstream dir h fs streamer = forM_ fs $ \file -> do
|
||||
let path = dir </> file
|
||||
sha <- hashFile h path
|
||||
streamer $ Git.UnionMerge.update_index_line
|
||||
sha (fileJournal file)
|
||||
removeFile path
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue