Browse Source

Always add FileExt to DfsPackDescription

Instead of forcing the implementation of the DFS backend to handle
making sure the extension bits are set correctly, have the common
callers in JGit set the extension at the same time they supply the
file sizes to the pack description. This simplifies assumptions for
an implementation of the DFS backend.

Change-Id: I55142ad8ea08a3e2e8349f72b3714578eba9c342
tags/v3.0.0.201305080800-m7
Shawn Pearce 11 years ago
parent
commit
7f1c2ec1eb

+ 3
- 0
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java View File

@@ -358,6 +358,7 @@ public class DfsGarbageCollector {
out = objdb.writeFile(pack, PACK);
try {
pw.writePack(pm, pm, out);
pack.addFileExt(PACK);
} finally {
out.close();
}
@@ -366,6 +367,7 @@ public class DfsGarbageCollector {
try {
CountingOutputStream cnt = new CountingOutputStream(out);
pw.writeIndex(cnt);
pack.addFileExt(INDEX);
pack.setFileSize(INDEX, cnt.getCount());
pack.setIndexVersion(pw.getIndexVersion());
} finally {
@@ -377,6 +379,7 @@ public class DfsGarbageCollector {
try {
CountingOutputStream cnt = new CountingOutputStream(out);
pw.writeBitmapIndex(cnt);
pack.addFileExt(BITMAP_INDEX);
pack.setFileSize(BITMAP_INDEX, cnt.getCount());
} finally {
out.close();

+ 2
- 0
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java View File

@@ -153,6 +153,7 @@ public class DfsInserter extends ObjectInserter {
throw new IOException();

byte[] packHash = packOut.writePackFooter();
packDsc.addFileExt(PACK);
packDsc.setFileSize(PACK, packOut.getCount());
packOut.close();
packOut = null;
@@ -261,6 +262,7 @@ public class DfsInserter extends ObjectInserter {
buf.writeTo(cnt, null);
else
index(cnt, packHash, list);
pack.addFileExt(INDEX);
pack.setFileSize(INDEX, cnt.getCount());
} finally {
os.close();

+ 2
- 0
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java View File

@@ -289,6 +289,7 @@ public class DfsPackCompactor {
DfsOutputStream out = objdb.writeFile(pack, PACK);
try {
pw.writePack(pm, pm, out);
pack.addFileExt(PACK);
} finally {
out.close();
}
@@ -301,6 +302,7 @@ public class DfsPackCompactor {
try {
CountingOutputStream cnt = new CountingOutputStream(out);
pw.writeIndex(cnt);
pack.addFileExt(INDEX);
pack.setFileSize(INDEX, cnt.getCount());
pack.setIndexVersion(pw.getIndexVersion());
} finally {

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java View File

@@ -148,6 +148,7 @@ public class DfsPackParser extends PackParser {
out = null;
currBuf = null;
readBlock = null;
packDsc.addFileExt(PACK);
packDsc.setFileSize(PACK, packEnd);

writePackIndex();

Loading…
Cancel
Save