Author: toad
Date: 2007-04-21 14:50:07 +0000 (Sat, 21 Apr 2007)
New Revision: 12842
Modified:
trunk/freenet/src/freenet/client/async/ClientGetter.java
trunk/freenet/src/freenet/clients/http/QueueToadlet.java
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
trunk/freenet/src/freenet/node/fcp/ClientGet.java
trunk/freenet/src/freenet/node/fcp/ClientRequest.java
Log:
Fix #911:
"Restart" becomes "Follow Redirect" when we have a permanent redirect to
follow. And if you click it, it will follow it.
Modified: trunk/freenet/src/freenet/client/async/ClientGetter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientGetter.java 2007-04-21
14:38:11 UTC (rev 12841)
+++ trunk/freenet/src/freenet/client/async/ClientGetter.java 2007-04-21
14:50:07 UTC (rev 12842)
@@ -23,7 +23,7 @@
public class ClientGetter extends BaseClientGetter {
final ClientCallback client;
- final FreenetURI uri;
+ FreenetURI uri;
final FetchContext ctx;
final ArchiveContext actx;
private ClientGetState currentState;
@@ -57,10 +57,10 @@
}
public void start() throws FetchException {
- start(false);
+ start(false, null);
}
- public boolean start(boolean restart) throws FetchException {
+ public boolean start(boolean restart, FreenetURI overrideURI) throws
FetchException {
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Starting "+this);
try {
@@ -68,6 +68,7 @@
// But we DEFINITELY do not want to synchronize while
calling currentState.schedule(),
// which can call onSuccess and thereby almost anything.
synchronized(this) {
+ if(overrideURI != null) uri = overrideURI;
if(finished) {
if(!restart) return false;
currentState = null;
@@ -205,8 +206,8 @@
return true;
}
- public boolean restart() throws FetchException {
- return start(true);
+ public boolean restart(FreenetURI redirect) throws FetchException {
+ return start(true, redirect);
}
public String toString() {
Modified: trunk/freenet/src/freenet/clients/http/QueueToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/QueueToadlet.java 2007-04-21
14:38:11 UTC (rev 12841)
+++ trunk/freenet/src/freenet/clients/http/QueueToadlet.java 2007-04-21
14:50:07 UTC (rev 12842)
@@ -784,8 +784,9 @@
if(clientRequest.hasFinished() && !clientRequest.hasSucceeded()
&& clientRequest.canRestart()) {
HTMLNode retryForm = ctx.addFormChild(deleteNode,
"/queue/", "queueRestartForm");
+ String restartName = L10n.getString(clientRequest
instanceof ClientGet && ((ClientGet)clientRequest).hasPermRedirect() ?
"QueueToadlet.follow" : "QueueToadlet.restart");
retryForm.addChild("input", new String[] { "type",
"name", "value" }, new String[] { "hidden", "identifier", identifier });
- retryForm.addChild("input", new String[] { "type",
"name", "value" }, new String[] { "submit", "restart_request",
L10n.getString("QueueToadlet.restart") });
+ retryForm.addChild("input", new String[] { "type",
"name", "value" }, new String[] { "submit", "restart_request", restartName });
}
return deleteNode;
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-04-21
14:38:11 UTC (rev 12841)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-04-21
14:50:07 UTC (rev 12842)
@@ -46,6 +46,7 @@
QueueToadlet.change=Change
QueueToadlet.delete=Delete
QueueToadlet.restart=Restart
+QueueToadlet.follow=Follow Redirect
QueueToadlet.insertFile=Insert File
QueueToadlet.insertAs=Insert as:
QueueToadlet.identifier=Identifier
Modified: trunk/freenet/src/freenet/node/fcp/ClientGet.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientGet.java 2007-04-21 14:38:11 UTC
(rev 12841)
+++ trunk/freenet/src/freenet/node/fcp/ClientGet.java 2007-04-21 14:50:07 UTC
(rev 12842)
@@ -665,8 +665,11 @@
public boolean restart() {
if(!canRestart()) return false;
+ FreenetURI redirect;
synchronized(this) {
finished = false;
+ redirect =
+ getFailedMessage == null ? null :
getFailedMessage.redirectURI;
this.getFailedMessage = null;
this.allDataPending = null;
this.postFetchProtocolErrorMessage = null;
@@ -674,8 +677,9 @@
started = false;
}
try {
- if(getter.restart()) {
+ if(getter.restart(redirect)) {
synchronized(this) {
+ if(redirect != null) this.uri =
redirect;
started = true;
}
}
@@ -685,4 +689,8 @@
return false;
}
}
+
+ public synchronized boolean hasPermRedirect() {
+ return getFailedMessage != null && getFailedMessage.redirectURI
!= null;
+ }
}
Modified: trunk/freenet/src/freenet/node/fcp/ClientRequest.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientRequest.java 2007-04-21
14:38:11 UTC (rev 12841)
+++ trunk/freenet/src/freenet/node/fcp/ClientRequest.java 2007-04-21
14:50:07 UTC (rev 12842)
@@ -16,7 +16,7 @@
public abstract class ClientRequest {
/** URI to fetch, or target URI to insert to */
- protected final FreenetURI uri;
+ protected FreenetURI uri;
/** Unique request identifier */
protected final String identifier;
/** Verbosity level. Relevant to all ClientRequests, although they
interpret it