Author: toad
Date: 2009-02-03 20:31:59 +0000 (Tue, 03 Feb 2009)
New Revision: 25514

Modified:
   branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
Log:
Fix NPEs etc, seems to more or less work now


Modified: 
branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java     
2009-02-03 20:27:49 UTC (rev 25513)
+++ branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java     
2009-02-03 20:31:59 UTC (rev 25514)
@@ -32,6 +32,7 @@
 import freenet.support.Logger;
 import freenet.support.SimpleFieldSet;
 import freenet.support.api.Bucket;
+import freenet.support.io.BucketTools;
 
 /**
  * Insert *ONE KEY*.
@@ -488,7 +489,14 @@
 
        private BlockItem getBlockItem(ObjectContainer container, ClientContext 
context) {
                try {
-                       return new BlockItem(this, sourceData, isMetadata, 
compressionCodec, sourceLength, uri, hashCode());
+                       if(persistent) container.activate(sourceData, 1);
+                       Bucket data = sourceData.createShadow();
+                       if(data == null) {
+                               data = 
context.tempBucketFactory.makeBucket(sourceData.size());
+                               BucketTools.copy(sourceData, data);
+                       }
+                       if(persistent) container.deactivate(sourceData, 1);
+                       return new BlockItem(this, data, isMetadata, 
compressionCodec, sourceLength, uri, hashCode());
                } catch (IOException e) {
                        fail(new InsertException(InsertException.BUCKET_ERROR, 
e, null), container, context);
                        return null;
@@ -516,7 +524,7 @@
                
                BlockItem(SingleBlockInserter parent, Bucket bucket, boolean 
meta, short codec, int srclen, FreenetURI u, int hashCode) throws IOException {
                        this.parent = parent;
-                       this.copyBucket = bucket.createShadow();
+                       this.copyBucket = bucket;
                        this.isMetadata = meta;
                        this.compressionCodec = codec;
                        this.sourceLength = srclen;

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to