From 7ebd98d8d829005c7dae38b789146d98e6800e5b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 14 Feb 2012 14:35:52 -0400 Subject: 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. --- Annex/Branch.hs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'Annex/Branch.hs') diff --git a/Annex/Branch.hs b/Annex/Branch.hs index 72a98ac16..f20c87b4a 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -1,6 +1,6 @@ {- management of the git-annex branch - - - Copyright 2011 Joey Hess + - Copyright 2011-2012 Joey Hess - - 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 -- cgit v1.2.3