Author: toad
Date: 2008-12-17 23:05:50 +0000 (Wed, 17 Dec 2008)
New Revision: 24490

Modified:
   branches/db4o/freenet/src/freenet/client/FetchContext.java
   branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
   branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java
   branches/db4o/freenet/src/freenet/node/fcp/ClientGet.java
   
branches/db4o/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
Log:
Make FetchContext.blocks final. Track whether we were responsible for it.


Modified: branches/db4o/freenet/src/freenet/client/FetchContext.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/FetchContext.java  2008-12-17 
22:57:08 UTC (rev 24489)
+++ branches/db4o/freenet/src/freenet/client/FetchContext.java  2008-12-17 
23:05:50 UTC (rev 24490)
@@ -8,7 +8,6 @@
 import com.db4o.ObjectContainer;
 
 import freenet.client.async.BlockSet;
-import freenet.client.async.USKManager;
 import freenet.client.events.ClientEventProducer;
 import freenet.client.events.SimpleEventProducer;
 import freenet.support.api.BucketFactory;
@@ -44,9 +43,10 @@
        public boolean returnZIPManifests;
        public final boolean ignoreTooManyPathComponents;
        /** If set, contains a set of blocks to be consulted before checking 
the datastore. */
-       public BlockSet blocks;
+       public final BlockSet blocks;
        public Set allowedMIMETypes;
        private final boolean hasOwnEventProducer;
+       private final boolean hasOwnBlocks;
        
        public FetchContext(long curMaxLength, 
                        long curMaxTempLength, int maxMetadataSize, int 
maxRecursionLevel, int maxArchiveRestarts, int maxArchiveLevels,
@@ -57,6 +57,8 @@
                        BucketFactory bucketFactory,
                        ClientEventProducer producer, boolean 
cacheLocalRequests, 
                        boolean ignoreTooManyPathComponents) {
+               hasOwnBlocks = false;
+               this.blocks = null;
                this.maxOutputLength = curMaxLength;
                this.maxTempLength = curMaxTempLength;
                this.maxMetadataSize = maxMetadataSize;
@@ -78,14 +80,18 @@
                hasOwnEventProducer = true;
        }
 
-       public FetchContext(FetchContext ctx, int maskID, boolean keepProducer) 
{
+       public FetchContext(FetchContext ctx, int maskID, boolean keepProducer, 
BlockSet blocks) {
                if(keepProducer)
                        this.eventProducer = ctx.eventProducer;
                else
                        this.eventProducer = new SimpleEventProducer();
                hasOwnEventProducer = !keepProducer;
                this.ignoreTooManyPathComponents = 
ctx.ignoreTooManyPathComponents;
-               this.blocks = ctx.blocks;
+               hasOwnBlocks = blocks != null;
+               if(blocks != null)
+                       this.blocks = blocks;
+               else
+                       this.blocks = ctx.blocks;
                this.allowedMIMETypes = ctx.allowedMIMETypes;
                if(maskID == IDENTICAL_MASK) {
                        this.maxOutputLength = ctx.maxOutputLength;

Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java       
2008-12-17 22:57:08 UTC (rev 24489)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java       
2008-12-17 23:05:50 UTC (rev 24490)
@@ -705,7 +705,7 @@
                Metadata newMeta = (Metadata) meta.clone();
                newMeta.setSimpleRedirect();
                final SingleFileFetcher f;
-               f = new SingleFileFetcher(this, newMeta, new 
ArchiveFetcherCallback(forData, element, callback), new FetchContext(ctx, 
FetchContext.SET_RETURN_ARCHIVES, true), container, context);
+               f = new SingleFileFetcher(this, newMeta, new 
ArchiveFetcherCallback(forData, element, callback), new FetchContext(ctx, 
FetchContext.SET_RETURN_ARCHIVES, true, null), container, context);
                if(persistent) container.store(f);
                if(logMINOR) Logger.minor(this, "fetchArchive(): "+f);
                // Fetch the archive. The archive fetcher callback will unpack 
it, and either call the element 

Modified: branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java        
2008-12-17 22:57:08 UTC (rev 24489)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java        
2008-12-17 23:05:50 UTC (rev 24490)
@@ -262,7 +262,7 @@
                if(persistent)
                        container.store(this);
                
-               blockFetchContext = new FetchContext(fetchContext, 
FetchContext.SPLITFILE_DEFAULT_BLOCK_MASK, true);
+               blockFetchContext = new FetchContext(fetchContext, 
FetchContext.SPLITFILE_DEFAULT_BLOCK_MASK, true, null);
                if(segmentCount == 1) {
                        // splitfile* will be overwritten, this is bad
                        // so copy them

Modified: branches/db4o/freenet/src/freenet/node/fcp/ClientGet.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/fcp/ClientGet.java   2008-12-17 
22:57:08 UTC (rev 24489)
+++ branches/db4o/freenet/src/freenet/node/fcp/ClientGet.java   2008-12-17 
23:05:50 UTC (rev 24490)
@@ -87,7 +87,7 @@
                                (persistRebootOnly ? 
ClientRequest.PERSIST_REBOOT : ClientRequest.PERSIST_FOREVER),
                                null, true);
 
-               fctx = new FetchContext(server.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false);
+               fctx = new FetchContext(server.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false, null);
                fctx.eventProducer.addEventListener(this);
                fctx.localRequestOnly = dsOnly;
                fctx.ignoreStore = ignoreDS;
@@ -127,7 +127,7 @@
                                message.persistenceType, message.clientToken, 
message.global);
                // Create a Fetcher directly in order to get more fine-grained 
control,
                // since the client may override a few context elements.
-               fctx = new FetchContext(server.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false);
+               fctx = new FetchContext(server.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false, null);
                fctx.eventProducer.addEventListener(this);
                // ignoreDS
                fctx.localRequestOnly = message.dsOnly;
@@ -209,7 +209,7 @@
                boolean ignoreDS = Fields.stringToBool(fs.get("IgnoreDS"), 
false);
                boolean dsOnly = Fields.stringToBool(fs.get("DSOnly"), false);
                int maxRetries = Integer.parseInt(fs.get("MaxRetries"));
-               fctx = new FetchContext(server.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false);
+               fctx = new FetchContext(server.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false, null);
                fctx.eventProducer.addEventListener(this);
                // ignoreDS
                fctx.localRequestOnly = dsOnly;

Modified: 
branches/db4o/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
===================================================================
--- 
branches/db4o/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java  
    2008-12-17 22:57:08 UTC (rev 24489)
+++ 
branches/db4o/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java  
    2008-12-17 23:05:50 UTC (rev 24490)
@@ -917,9 +917,9 @@
 
                // Fetch our revocation key from the datastore plus the binary 
blob
 
-               FetchContext tempContext = 
updateManager.node.clientCore.makeClient((short) 0, true).getFetchContext();
+               FetchContext seedContext = 
updateManager.node.clientCore.makeClient((short) 0, true).getFetchContext();
+               FetchContext tempContext = new FetchContext(seedContext, 
FetchContext.IDENTICAL_MASK, true, blocks);
                tempContext.localRequestOnly = true;
-               tempContext.blocks = blocks;
 
                File f;
                FileBucket b = null;
@@ -1418,9 +1418,9 @@
 
                // Fetch the jar from the datastore plus the binary blob
 
-               FetchContext tempContext = 
updateManager.node.clientCore.makeClient((short) 0, true).getFetchContext();
+               FetchContext seedContext = 
updateManager.node.clientCore.makeClient((short) 0, true).getFetchContext();
+               FetchContext tempContext = new FetchContext(seedContext, 
FetchContext.IDENTICAL_MASK, true, blocks);
                tempContext.localRequestOnly = true;
-               tempContext.blocks = blocks;
 
                File f;
                FileBucket b = null;
@@ -1541,9 +1541,9 @@
 
                // Fetch the jar from the datastore plus the binary blob
 
-               FetchContext tempContext = 
updateManager.node.clientCore.makeClient((short) 0, true).getFetchContext();
+               FetchContext seedContext = 
updateManager.node.clientCore.makeClient((short) 0, true).getFetchContext();
+               FetchContext tempContext = new FetchContext(seedContext, 
FetchContext.IDENTICAL_MASK, true, blocks);
                tempContext.localRequestOnly = true;
-               tempContext.blocks = blocks;
 
                File f;
                FileBucket b = null;

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

Reply via email to