Author: toad
Date: 2008-11-08 14:15:06 +0000 (Sat, 08 Nov 2008)
New Revision: 23422
Modified:
trunk/freenet/src/freenet/client/async/SplitFileInserter.java
Log:
Back compatibility for resuming old inserts, which were saved with
CompressionCodec as a numerical value.
Don't write anything for CompressionCodec if the data is not compressed.
Modified: trunk/freenet/src/freenet/client/async/SplitFileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileInserter.java
2008-11-08 11:43:33 UTC (rev 23421)
+++ trunk/freenet/src/freenet/client/async/SplitFileInserter.java
2008-11-08 14:15:06 UTC (rev 23422)
@@ -53,7 +53,8 @@
fs.putSingle("Type", "SplitFileInserter");
fs.put("DataLength", dataLength);
fs.put("DecompressedLength", decompressedLength);
- fs.putSingle("CompressionCodec", compressionCodec.toString());
+ if(compressionCodec != null)
+ fs.putSingle("CompressionCodec",
compressionCodec.toString());
fs.put("SplitfileCodec", splitfileAlgorithm);
fs.put("Finished", finished);
fs.put("SegmentSize", segmentSize);
@@ -147,9 +148,20 @@
throw new ResumeException("Corrupt CheckSegmentSize:
"+e+" : "+length);
}
String ccodec = fs.get("CompressionCodec");
- if(ccodec == null)
- throw new ResumeException("No compression codec");
- compressionCodec = COMPRESSOR_TYPE.valueOf(ccodec);
+ COMPRESSOR_TYPE compressor = null;
+ if(ccodec != null) {
+ try {
+ compressor = COMPRESSOR_TYPE.valueOf(ccodec);
+ } catch (Throwable t) {
+ try {
+ short codecNo =
Short.parseShort(ccodec);
+ compressor =
COMPRESSOR_TYPE.getCompressorByMetadataID(codecNo);
+ } catch (NumberFormatException nfe) {
+ throw new ResumeException("Invalid
compression codec: "+ccodec);
+ }
+ }
+ }
+ compressionCodec = compressor;
String scodec = fs.get("SplitfileCodec");
if(scodec == null) throw new ResumeException("No splitfile
codec");
try {