diff options
author | Anna Papitto <annapapitto@google.com> | 2023-05-30 16:20:54 +0200 |
---|---|---|
committer | Anna Papitto <annapapitto@google.com> | 2023-05-31 10:09:50 +0200 |
commit | 181b629f7deea1750b8e5d2160750ed2cef91c3d (patch) | |
tree | eeffa060e46a3cdb9ef06caacbd9d2080e1ba209 /org.eclipse.jgit | |
parent | 0f071a7bcee1f551652b2ae017f3e0e134c7eb74 (diff) | |
download | jgit-181b629f7deea1750b8e5d2160750ed2cef91c3d.tar.gz jgit-181b629f7deea1750b8e5d2160750ed2cef91c3d.zip |
Gc#writePack: write the reverse index file to disk
The reverse index is currently created in-memory when needed. A writer
for reverse index files was already implemented.
Make garbage collection write the reverse index file when the PackConfig
enables it. Write it during #writePack, which mirrors how the primary
index is written.
Change-Id: I50131af6622c41a7b24534aaaf2a423ab4178981
Signed-off-by: Anna Papitto <annapapitto@google.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java index 11757aabda..10b53b6661 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java @@ -1323,6 +1323,25 @@ public class GC { idxChannel.force(true); } + if (pw.isReverseIndexEnabled()) { + File tmpReverseIndexFile = new File(packdir, + tmpBase + REVERSE_INDEX.getTmpExtension()); + tmpExts.put(REVERSE_INDEX, tmpReverseIndexFile); + if (!tmpReverseIndexFile.createNewFile()) { + throw new IOException(MessageFormat.format( + JGitText.get().cannotCreateIndexfile, + tmpReverseIndexFile.getPath())); + } + try (FileOutputStream fos = new FileOutputStream( + tmpReverseIndexFile); + FileChannel channel = fos.getChannel(); + OutputStream stream = Channels + .newOutputStream(channel)) { + pw.writeReverseIndex(stream); + channel.force(true); + } + } + if (pw.prepareBitmapIndex(pm)) { File tmpBitmapIdx = new File(packdir, tmpBase + BITMAP_INDEX.getTmpExtension()); |