Author: toad
Date: 2009-01-24 20:02:46 +0000 (Sat, 24 Jan 2009)
New Revision: 25292
Added:
branches/db4o/freenet/src/freenet/support/io/NotPersistentBucket.java
Modified:
branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
Log:
If it's been sent to a SegmentedBCB, but it fits in a single block, we need to
copy it and then free it.
Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
2009-01-24 20:02:06 UTC (rev 25291)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
2009-01-24 20:02:46 UTC (rev 25292)
@@ -29,6 +29,7 @@
import freenet.support.io.BucketChainBucketFactory;
import freenet.support.io.BucketTools;
import freenet.support.io.NativeThread;
+import freenet.support.io.NotPersistentBucket;
/**
* Attempt to insert a file. May include metadata.
@@ -247,6 +248,19 @@
}
if (fitsInOneCHK) {
// Insert single block, then insert pointer to it
+ if(persistent && !(data instanceof
NotPersistentBucket)) {
+ try {
+ Bucket newData =
context.persistentBucketFactory.makeBucket(data.size());
+ BucketTools.copy(data, newData);
+ data.free();
+ data = newData;
+ } catch (IOException e) {
+ Logger.error(this, "Caught "+e+" while
copying non-persistent data", e);
+ throw new
InsertException(InsertException.BUCKET_ERROR, e, null);
+ }
+ // Note that SegmentedBCB *does* support
splitting, so we don't need to do anything to the data
+ // if it doesn't fit in a single block.
+ }
if(reportMetadataOnly) {
SingleBlockInserter dataPutter = new
SingleBlockInserter(parent, data, codecNumber, FreenetURI.EMPTY_CHK_URI, ctx,
cb, metadata, (int)origSize, -1, getCHKOnly, true, true, token, container,
context, persistent, freeData);
if(logMINOR)
Added: branches/db4o/freenet/src/freenet/support/io/NotPersistentBucket.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/io/NotPersistentBucket.java
(rev 0)
+++ branches/db4o/freenet/src/freenet/support/io/NotPersistentBucket.java
2009-01-24 20:02:46 UTC (rev 25292)
@@ -0,0 +1,10 @@
+package freenet.support.io;
+
+import freenet.support.api.Bucket;
+
+// A Bucket which does not support being stored to the database. E.g.
SegmentedBCB.
+public interface NotPersistentBucket extends Bucket {
+
+ // No methods
+
+}
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs