|
|
@@ -75,6 +75,8 @@ import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.concurrent.Future; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.zip.CRC32; |
|
|
|
import java.util.zip.CheckedOutputStream; |
|
|
|
import java.util.zip.Deflater; |
|
|
|
import java.util.zip.DeflaterOutputStream; |
|
|
|
|
|
|
@@ -275,12 +277,16 @@ public class PackWriter { |
|
|
|
|
|
|
|
private boolean canBuildBitmaps; |
|
|
|
|
|
|
|
private boolean indexDisabled; |
|
|
|
|
|
|
|
private int depth; |
|
|
|
|
|
|
|
private Collection<? extends ObjectId> unshallowObjects; |
|
|
|
|
|
|
|
private PackBitmapIndexBuilder writeBitmaps; |
|
|
|
|
|
|
|
private CRC32 crc32; |
|
|
|
|
|
|
|
/** |
|
|
|
* Create writer for specified repository. |
|
|
|
* <p> |
|
|
@@ -471,6 +477,19 @@ public class PackWriter { |
|
|
|
this.useBitmaps = useBitmaps; |
|
|
|
} |
|
|
|
|
|
|
|
/** @return true if the index file cannot be created by this PackWriter. */ |
|
|
|
public boolean isIndexDisabled() { |
|
|
|
return indexDisabled || !cachedPacks.isEmpty(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param noIndex |
|
|
|
* true to disable creation of the index file. |
|
|
|
*/ |
|
|
|
public void setIndexDisabled(boolean noIndex) { |
|
|
|
this.indexDisabled = noIndex; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @return true to ignore objects that are uninteresting and also not found |
|
|
|
* on local disk; false to throw a {@link MissingObjectException} |
|
|
@@ -855,7 +874,7 @@ public class PackWriter { |
|
|
|
* the index data could not be written to the supplied stream. |
|
|
|
*/ |
|
|
|
public void writeIndex(final OutputStream indexStream) throws IOException { |
|
|
|
if (!cachedPacks.isEmpty()) |
|
|
|
if (isIndexDisabled()) |
|
|
|
throw new IOException(JGitText.get().cachedPacksPreventsIndexCreation); |
|
|
|
|
|
|
|
long writeStart = System.currentTimeMillis(); |
|
|
@@ -996,8 +1015,13 @@ public class PackWriter { |
|
|
|
if (config.isDeltaCompress()) |
|
|
|
searchForDeltas(compressMonitor); |
|
|
|
|
|
|
|
final PackOutputStream out = new PackOutputStream(writeMonitor, |
|
|
|
packStream, this); |
|
|
|
crc32 = new CRC32(); |
|
|
|
final PackOutputStream out = new PackOutputStream( |
|
|
|
writeMonitor, |
|
|
|
isIndexDisabled() |
|
|
|
? packStream |
|
|
|
: new CheckedOutputStream(packStream, crc32), |
|
|
|
this); |
|
|
|
|
|
|
|
long objCnt = getObjectCount(); |
|
|
|
stats.totalObjects = objCnt; |
|
|
@@ -1484,12 +1508,12 @@ public class PackWriter { |
|
|
|
if (otp.isWritten()) |
|
|
|
return; // Delta chain cycle caused this to write already. |
|
|
|
|
|
|
|
out.resetCRC32(); |
|
|
|
crc32.reset(); |
|
|
|
otp.setOffset(out.length()); |
|
|
|
try { |
|
|
|
reuseSupport.copyObjectAsIs(out, otp, reuseValidate); |
|
|
|
out.endObject(); |
|
|
|
otp.setCRC(out.getCRC32()); |
|
|
|
otp.setCRC((int) crc32.getValue()); |
|
|
|
typeStats.reusedObjects++; |
|
|
|
if (otp.isDeltaRepresentation()) { |
|
|
|
typeStats.reusedDeltas++; |
|
|
@@ -1523,7 +1547,7 @@ public class PackWriter { |
|
|
|
else |
|
|
|
writeWholeObjectDeflate(out, otp); |
|
|
|
out.endObject(); |
|
|
|
otp.setCRC(out.getCRC32()); |
|
|
|
otp.setCRC((int) crc32.getValue()); |
|
|
|
} |
|
|
|
|
|
|
|
private void writeBase(PackOutputStream out, ObjectToPack base) |
|
|
@@ -1537,7 +1561,7 @@ public class PackWriter { |
|
|
|
final Deflater deflater = deflater(); |
|
|
|
final ObjectLoader ldr = reader.open(otp, otp.getType()); |
|
|
|
|
|
|
|
out.resetCRC32(); |
|
|
|
crc32.reset(); |
|
|
|
otp.setOffset(out.length()); |
|
|
|
out.writeHeader(otp, ldr.getSize()); |
|
|
|
|
|
|
@@ -1551,7 +1575,7 @@ public class PackWriter { |
|
|
|
final ObjectToPack otp) throws IOException { |
|
|
|
writeBase(out, otp.getDeltaBase()); |
|
|
|
|
|
|
|
out.resetCRC32(); |
|
|
|
crc32.reset(); |
|
|
|
otp.setOffset(out.length()); |
|
|
|
|
|
|
|
DeltaCache.Ref ref = otp.popCachedDelta(); |