Author: toad
Date: 2008-06-20 00:56:30 +0000 (Fri, 20 Jun 2008)
New Revision: 20514

Modified:
   branches/db4o/freenet/src/freenet/client/InsertContext.java
   branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
   branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
   branches/db4o/freenet/src/freenet/node/fcp/ClientPutBase.java
Log:
Remove non-persistent (therefore unsafe) bucket factory from InsertContext

Modified: branches/db4o/freenet/src/freenet/client/InsertContext.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/InsertContext.java 2008-06-20 
00:52:37 UTC (rev 20513)
+++ branches/db4o/freenet/src/freenet/client/InsertContext.java 2008-06-20 
00:56:30 UTC (rev 20514)
@@ -5,17 +5,14 @@

 import com.db4o.ObjectContainer;

-import freenet.client.async.USKManager;
 import freenet.client.events.ClientEventProducer;
 import freenet.client.events.SimpleEventProducer;
 import freenet.support.api.BucketFactory;
-import freenet.support.io.NullPersistentFileTracker;
 import freenet.support.io.PersistentFileTracker;

 /** Context object for an insert operation, including both simple and 
multi-file inserts */
 public class InsertContext {

-       public final BucketFactory bf;
        public final BucketFactory persistentBucketFactory;
        public final PersistentFileTracker persistentFileTracker;
        /** If true, don't try to compress the data */
@@ -33,7 +30,6 @@
        public InsertContext(BucketFactory bf, BucketFactory persistentBF, 
PersistentFileTracker tracker,
                        int maxRetries, int rnfsToSuccess, int maxThreads, int 
splitfileSegmentDataBlocks, int splitfileSegmentCheckBlocks,
                        ClientEventProducer eventProducer, boolean 
cacheLocalRequests) {
-               this.bf = bf;
                this.persistentFileTracker = tracker;
                this.persistentBucketFactory = persistentBF;
                dontCompress = false;
@@ -47,24 +43,8 @@
                this.cacheLocalRequests = cacheLocalRequests;
        }

-       public InsertContext(InsertContext ctx, SimpleEventProducer producer, 
boolean forceNonPersistent) {
-               this.persistentFileTracker = forceNonPersistent ? new 
NullPersistentFileTracker() : ctx.persistentFileTracker;
-               this.bf = ctx.bf;
-               this.persistentBucketFactory = forceNonPersistent ? ctx.bf : 
ctx.persistentBucketFactory;
-               this.dontCompress = ctx.dontCompress;
-               this.splitfileAlgorithm = ctx.splitfileAlgorithm;
-               this.consecutiveRNFsCountAsSuccess = 
ctx.consecutiveRNFsCountAsSuccess;
-               this.maxInsertRetries = ctx.maxInsertRetries;
-               this.maxSplitInsertThreads = ctx.maxSplitInsertThreads;
-               this.eventProducer = producer;
-               this.splitfileSegmentDataBlocks = 
ctx.splitfileSegmentDataBlocks;
-               this.splitfileSegmentCheckBlocks = 
ctx.splitfileSegmentCheckBlocks;
-               this.cacheLocalRequests = ctx.cacheLocalRequests;
-       }
-
        public InsertContext(InsertContext ctx, SimpleEventProducer producer) {
                this.persistentFileTracker = ctx.persistentFileTracker;
-               this.bf = ctx.bf;
                this.persistentBucketFactory = ctx.persistentBucketFactory;
                this.dontCompress = ctx.dontCompress;
                this.splitfileAlgorithm = ctx.splitfileAlgorithm;

Modified: 
branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java    
2008-06-20 00:52:37 UTC (rev 20513)
+++ branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java    
2008-06-20 00:56:30 UTC (rev 20514)
@@ -368,7 +368,7 @@
                }
                while(true) {
                        try {
-                               bucket = 
BucketTools.makeImmutableBucket(ctx.bf, baseMetadata.writeToByteArray());
+                               bucket = 
BucketTools.makeImmutableBucket(context.getBucketFactory(persistent()), 
baseMetadata.writeToByteArray());
                                break;
                        } catch (IOException e) {
                                fail(new 
InsertException(InsertException.BUCKET_ERROR, e, null), container);
@@ -403,7 +403,7 @@
                                // FIXME support formats other than .zip.
                                // Only the *decoding* is generic at present.

-                               Bucket zipBucket = ctx.bf.makeBucket(-1);
+                               Bucket zipBucket = 
context.getBucketFactory(persistent()).makeBucket(-1);
                                OutputStream os = new 
BufferedOutputStream(zipBucket.getOutputStream());
                                ZipOutputStream zos = new ZipOutputStream(os);
                                ZipEntry ze;
@@ -468,7 +468,7 @@
                                if(metadataPuttersByMetadata.containsKey(m)) 
continue;
                        }
                        try {
-                               Bucket b = m.toBucket(ctx.bf);
+                               Bucket b = 
m.toBucket(context.getBucketFactory(persistent()));

                                InsertBlock ib = new InsertBlock(b, null, 
FreenetURI.EMPTY_CHK_URI);
                                SingleFileInserter metadataInserter = 

Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java      
2008-06-20 00:52:37 UTC (rev 20513)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java      
2008-06-20 00:56:30 UTC (rev 20514)
@@ -209,7 +209,7 @@
                                Metadata meta = 
makeMetadata(dataPutter.getURI(container, context));
                                Bucket metadataBucket;
                                try {
-                                       metadataBucket = 
BucketTools.makeImmutableBucket(ctx.bf, meta.writeToByteArray());
+                                       metadataBucket = 
BucketTools.makeImmutableBucket(context.getBucketFactory(parent.persistent()), 
meta.writeToByteArray());
                                } catch (IOException e) {
                                        Logger.error(this, "Caught "+e, e);
                                        throw new 
InsertException(InsertException.BUCKET_ERROR, e, null);
@@ -274,7 +274,7 @@

                boolean tryCompress = (origSize > blockSize) && 
(!ctx.dontCompress) && (!dontCompress);
                if(tryCompress) {
-                       InsertCompressor.start(container, context, this, 
origData, oneBlockCompressedSize, ctx.bf, parent.persistent());
+                       InsertCompressor.start(container, context, this, 
origData, oneBlockCompressedSize, 
context.getBucketFactory(parent.persistent()), parent.persistent());
                } else {
                        CompressionOutput output = new CompressionOutput(data, 
null);
                        onCompressed(output, container, context);

Modified: branches/db4o/freenet/src/freenet/node/fcp/ClientPutBase.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/fcp/ClientPutBase.java       
2008-06-20 00:52:37 UTC (rev 20513)
+++ branches/db4o/freenet/src/freenet/node/fcp/ClientPutBase.java       
2008-06-20 00:56:30 UTC (rev 20514)
@@ -63,7 +63,7 @@
                        boolean dontCompress, int maxRetries, boolean 
earlyEncode, FCPServer server) throws MalformedURLException {
                super(uri, identifier, verbosity, handler, priorityClass, 
persistenceType, clientToken, global);
                this.getCHKOnly = getCHKOnly;
-               ctx = new InsertContext(server.defaultInsertContext, new 
SimpleEventProducer(), persistenceType == ClientRequest.PERSIST_CONNECTION);
+               ctx = new InsertContext(server.defaultInsertContext, new 
SimpleEventProducer());
                ctx.dontCompress = dontCompress;
                ctx.eventProducer.addEventListener(this);
                ctx.maxInsertRetries = maxRetries;
@@ -76,7 +76,7 @@
                        boolean getCHKOnly, boolean dontCompress, int 
maxRetries, boolean earlyEncode, FCPServer server) throws MalformedURLException 
{
                super(uri, identifier, verbosity, handler, client, 
priorityClass, persistenceType, clientToken, global);
                this.getCHKOnly = getCHKOnly;
-               ctx = new InsertContext(server.defaultInsertContext, new 
SimpleEventProducer(), persistenceType == ClientRequest.PERSIST_CONNECTION);
+               ctx = new InsertContext(server.defaultInsertContext, new 
SimpleEventProducer());
                ctx.dontCompress = dontCompress;
                ctx.eventProducer.addEventListener(this);
                ctx.maxInsertRetries = maxRetries;


Reply via email to