Author: toad
Date: 2006-01-31 23:57:32 +0000 (Tue, 31 Jan 2006)
New Revision: 7980
Modified:
trunk/freenet/src/freenet/client/async/ClientPutter.java
trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
trunk/freenet/src/freenet/client/async/SingleFileInserter.java
trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
trunk/freenet/src/freenet/node/Version.java
Log:
423:
Fix a few bugs in GETCHKFILE.
Modified: trunk/freenet/src/freenet/client/async/ClientPutter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientPutter.java 2006-01-31
23:56:05 UTC (rev 7979)
+++ trunk/freenet/src/freenet/client/async/ClientPutter.java 2006-01-31
23:57:32 UTC (rev 7980)
@@ -41,7 +41,7 @@
public void start() throws InserterException {
try {
currentState =
- new SingleFileInserter(this, this, new
InsertBlock(data, cm, targetURI), isMetadata, ctx, false, false, getCHKOnly,
false);
+ new SingleFileInserter(this, this, new
InsertBlock(data, cm, targetURI), isMetadata, ctx, false, getCHKOnly, false);
((SingleFileInserter)currentState).start();
} catch (InserterException e) {
finished = true;
Modified: trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
2006-01-31 23:56:05 UTC (rev 7979)
+++ trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
2006-01-31 23:57:32 UTC (rev 7980)
@@ -30,7 +30,7 @@
InsertBlock block =
new InsertBlock(data, cm,
FreenetURI.EMPTY_CHK_URI);
this.origSFI =
- new SingleFileInserter(this, this, block,
false, ctx, false, true, getCHKOnly, false);
+ new SingleFileInserter(this, this, block,
false, ctx, false, getCHKOnly, false);
currentState = origSFI;
metadata = null;
}
@@ -251,7 +251,7 @@
new InsertBlock(bucket, null, targetURI);
try {
SingleFileInserter metadataInserter =
- new SingleFileInserter(this, this, block, true,
ctx, false, false, getCHKOnly, false);
+ new SingleFileInserter(this, this, block, true,
ctx, false, getCHKOnly, false);
this.currentMetadataInserterState = metadataInserter;
metadataInserter.start();
} catch (InserterException e) {
Modified: trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
2006-01-31 23:56:05 UTC (rev 7979)
+++ trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
2006-01-31 23:57:32 UTC (rev 7980)
@@ -38,6 +38,7 @@
private SoftReference refToClientKeyBlock;
final int token; // for e.g. splitfiles
final boolean isMetadata;
+ final boolean getCHKOnly;
final int sourceLength;
private int consecutiveRNFs;
@@ -55,12 +56,7 @@
this.sourceData = data;
this.isMetadata = isMetadata;
this.sourceLength = sourceLength;
- if(getCHKOnly) {
- ClientKeyBlock block = encode();
- cb.onEncode(block.getClientKey(), this);
- cb.onSuccess(this);
- finished = true;
- }
+ this.getCHKOnly = getCHKOnly;
if(addToParent) {
parent.addBlock();
parent.addMustSucceedBlocks(1);
@@ -191,9 +187,17 @@
}
}
- public void schedule() {
+ public void schedule() throws InserterException {
if(finished) return;
- parent.scheduler.register(this);
+ if(getCHKOnly) {
+ ClientKeyBlock block = encode();
+ cb.onEncode(block.getClientKey(), this);
+ cb.onSuccess(this);
+ parent.completedBlock(false);
+ finished = true;
+ } else {
+ parent.scheduler.register(this);
+ }
}
public FreenetURI getURI() {
Modified: trunk/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleFileInserter.java
2006-01-31 23:56:05 UTC (rev 7979)
+++ trunk/freenet/src/freenet/client/async/SingleFileInserter.java
2006-01-31 23:57:32 UTC (rev 7980)
@@ -37,7 +37,6 @@
final boolean getCHKOnly;
/** If true, we are not the top level request, and should not
* update our parent to point to us as current put-stage. */
- final boolean dontTellParent;
private boolean cancelled = false;
private boolean reportMetadataOnly;
@@ -48,21 +47,19 @@
* @param metadata
* @param ctx
* @param dontCompress
- * @param dontTellParent
* @param getCHKOnly
* @param reportMetadataOnly If true, don't insert the metadata, just
report it.
* @throws InserterException
*/
SingleFileInserter(BaseClientPutter parent, PutCompletionCallback cb,
InsertBlock block,
boolean metadata, InserterContext ctx, boolean
dontCompress,
- boolean dontTellParent, boolean getCHKOnly, boolean
reportMetadataOnly) throws InserterException {
+ boolean getCHKOnly, boolean reportMetadataOnly) throws
InserterException {
this.reportMetadataOnly = reportMetadataOnly;
this.parent = parent;
this.block = block;
this.ctx = ctx;
this.metadata = metadata;
this.cb = cb;
- this.dontTellParent = dontTellParent;
this.getCHKOnly = getCHKOnly;
}
@@ -157,9 +154,9 @@
if(data.size() < blockSize) {
// Just insert it
SingleBlockInserter bi = new
SingleBlockInserter(parent, data, codecNumber, block.desiredURI, ctx, cb,
metadata, (int)block.getData().size(), -1, getCHKOnly, true);
+ cb.onTransition(this, bi);
bi.schedule();
cb.onBlockSetFinished(this);
- cb.onTransition(this, bi);
return;
}
}
@@ -246,7 +243,7 @@
Logger.minor(this, "Metadata insert
succeeded");
metaInsertSuccess = true;
} else {
- Logger.error(this, "Unknown: "+state);
+ Logger.error(this, "Unknown: "+state,
new Exception("debug"));
}
if(splitInsertSuccess && metaInsertSuccess) {
Logger.minor(this, "Both succeeded");
@@ -286,7 +283,7 @@
}
InsertBlock newBlock = new
InsertBlock(metadataBucket, null, block.desiredURI);
try {
- metadataPutter = new
SingleFileInserter(parent, this, newBlock, true, ctx, false, getCHKOnly, false,
false);
+ metadataPutter = new
SingleFileInserter(parent, this, newBlock, true, ctx, false, getCHKOnly, false);
Logger.minor(this, "Putting
metadata on "+metadataPutter);
} catch (InserterException e) {
cb.onFailure(e, this);
Modified: trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2006-01-31 23:56:05 UTC (rev 7979)
+++ trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2006-01-31 23:57:32 UTC (rev 7980)
@@ -27,7 +27,7 @@
final int segNo;
private boolean encoded;
private boolean finished;
- private boolean getCHKOnly;
+ private final boolean getCHKOnly;
private boolean hasURIs;
private InserterException toThrow;
private final FailureCodeTracker errors;
@@ -36,6 +36,7 @@
public SplitFileInserterSegment(SplitFileInserter parent, FECCodec
splitfileAlgo, Bucket[] origDataBlocks, InserterContext blockInsertContext,
boolean getCHKOnly, int segNo) {
this.parent = parent;
+ this.getCHKOnly = getCHKOnly;
this.errors = new FailureCodeTracker(true);
this.blockInsertContext = blockInsertContext;
this.splitfileAlgo = splitfileAlgo;
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-01-31 23:56:05 UTC (rev
7979)
+++ trunk/freenet/src/freenet/node/Version.java 2006-01-31 23:57:32 UTC (rev
7980)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 422;
+ private static final int buildNumber = 423;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 403;