Author: toad
Date: 2006-12-12 02:58:27 +0000 (Tue, 12 Dec 2006)
New Revision: 11353

Modified:
   trunk/freenet/src/freenet/client/async/SingleFileInserter.java
Log:
Don't send FinishedCompression if we didn't try to compress anything.

Modified: trunk/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleFileInserter.java      
2006-12-12 02:54:51 UTC (rev 11352)
+++ trunk/freenet/src/freenet/client/async/SingleFileInserter.java      
2006-12-12 02:58:27 UTC (rev 11353)
@@ -147,7 +147,8 @@
                Compressor bestCodec = null;
                Bucket bestCompressedData = null;

-               if((origSize > blockSize) && (!ctx.dontCompress) && 
(!dontCompress)) {
+               boolean tryCompress = (origSize > blockSize) && 
(!ctx.dontCompress) && (!dontCompress);
+               if(tryCompress) {
                        // Try to compress the data.
                        // Try each algorithm, starting with the fastest and 
weakest.
                        // Stop when run out of algorithms, or the compressed 
data fits in a single block.
@@ -188,7 +189,8 @@
                }

                if(parent == cb) {
-                       ctx.eventProducer.produceEvent(new 
FinishedCompressionEvent(bestCodec == null ? -1 : 
bestCodec.codecNumberForMetadata(), origSize, data.size()));
+                       if(tryCompress)
+                               ctx.eventProducer.produceEvent(new 
FinishedCompressionEvent(bestCodec == null ? -1 : 
bestCodec.codecNumberForMetadata(), origSize, data.size()));
                        if(logMINOR) Logger.minor(this, "Compressed 
"+origSize+" to "+data.size()+" on "+this);
                }



Reply via email to