summaryrefslogtreecommitdiff
path: root/Annex/Branch.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-02-14 14:35:52 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-02-14 14:37:59 -0400
commit7ebd98d8d829005c7dae38b789146d98e6800e5b (patch)
treee20bfa80563081153d712633eb25b8c6a0f5fc78 /Annex/Branch.hs
parentcdd6cdbb67ea87a4a03357fb75c22d432fa2e15d (diff)
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.
Diffstat (limited to 'Annex/Branch.hs')
-rw-r--r--Annex/Branch.hs23
1 files changed, 12 insertions, 11 deletions
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 <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