Author: saces
Date: 2008-07-29 11:46:01 +0000 (Tue, 29 Jul 2008)
New Revision: 21468
Modified:
trunk/freenet/src/freenet/pluginmanager/PluginDownLoaderFreenet.java
Log:
deal with PERMANENT_REDIRECT and TOO_MANY_PATH_COMPONENTS
Modified: trunk/freenet/src/freenet/pluginmanager/PluginDownLoaderFreenet.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginDownLoaderFreenet.java
2008-07-29 11:22:18 UTC (rev 21467)
+++ trunk/freenet/src/freenet/pluginmanager/PluginDownLoaderFreenet.java
2008-07-29 11:46:01 UTC (rev 21468)
@@ -15,9 +15,12 @@
public class PluginDownLoaderFreenet extends PluginDownLoader<FreenetURI> {
+ private boolean logMINOR;
+
final HighLevelSimpleClient hlsc;
-
+
PluginDownLoaderFreenet(HighLevelSimpleClient hlsc) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.hlsc = hlsc;
}
@@ -32,12 +35,19 @@
@Override
InputStream getInputStream() throws IOException,
PluginNotFoundException {
- try {
- FetchResult fres = hlsc.fetch(getSource());
- return fres.asBucket().getInputStream();
- } catch (FetchException e) {
- Logger.error(this, "error while fetching plugin: " +
getSource(), e);
- throw new PluginNotFoundException("error while fetching
plugin: " + getSource(), e);
+ FreenetURI uri = getSource();
+ while (true) {
+ try {
+ FetchResult fres = hlsc.fetch(uri);
+ return fres.asBucket().getInputStream();
+ } catch (FetchException e) {
+ if ((e.getMode() ==
FetchException.PERMANENT_REDIRECT) || (e.getMode() ==
FetchException.TOO_MANY_PATH_COMPONENTS)) {
+ uri = e.newURI;
+ continue;
+ }
+ Logger.error(this, "error while fetching
plugin: " + getSource(), e);
+ throw new PluginNotFoundException("error while
fetching plugin: " + getSource(), e);
+ }
}
}