Author: toad
Date: 2008-12-24 19:39:14 +0000 (Wed, 24 Dec 2008)
New Revision: 24785
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
Log:
Pad the last block of a splitfile BEFORE INSERT, not during FEC encoding.
Insert it padded.
The main advantage is that the padding algorithm is no longer a problem for a
client downloading a file.
Current code should truncate the file correctly, however this has not yet been
tested.
This is also helpful for the db4o branch as we cannot free persistent buckets
in the FEC codec, however we cannot remove that code until the next commit
where we make split file fetchers pad before calling FEC encode for healing.
REQUEST BACKPORT TO TRUNK.
Modified: branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
2008-12-24 19:32:00 UTC (rev 24784)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
2008-12-24 19:39:14 UTC (rev 24785)
@@ -104,6 +104,13 @@
if(freeData) {
// BucketTools.split will free it but not
removeFrom().
data.removeFrom(container);
+ if(dataBuckets[dataBuckets.length-1].size() <
CHKBlock.DATA_LENGTH) {
+ Bucket oldData =
dataBuckets[dataBuckets.length-1];
+ dataBuckets[dataBuckets.length-1] =
BucketTools.pad(oldData, CHKBlock.DATA_LENGTH, context.persistentBucketFactory,
(int) oldData.size());
+ if(persistent)
dataBuckets[dataBuckets.length-1].storeTo(container);
+ oldData.free();
+ if(persistent)
oldData.removeFrom(container);
+ }
}
if(logMINOR)
Logger.minor(this, "Data size "+data.size()+"
buckets "+dataBuckets.length);
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs