* @return The result of the fetch, or {@code null} if an error occured
*/
public FetchResult fetchUri(FreenetURI uri) {
- logger.entering(FreenetInterface.class.getName(), "fetchUri(FreenetURI)", uri);
FetchResult fetchResult = null;
- try {
- fetchResult = client.fetch(uri);
- } catch (FetchException fe1) {
- logger.log(Level.WARNING, "Could not fetch “" + uri + "”!", fe1);
- } finally {
- logger.exiting(FreenetInterface.class.getName(), "fetchUri(FreenetURI)", fetchResult);
+ FreenetURI currentUri = new FreenetURI(uri);
+ while (true) {
+ try {
+ fetchResult = client.fetch(currentUri);
+ return fetchResult;
+ } catch (FetchException fe1) {
+ if (fe1.getMode() == FetchException.PERMANENT_REDIRECT) {
+ currentUri = fe1.newURI;
+ continue;
+ }
+ logger.log(Level.WARNING, "Could not fetch “" + uri + "”!", fe1);
+ return null;
+ }
}
- return fetchResult;
}
/**
@Override
@SuppressWarnings("synthetic-access")
public void onFoundEdition(long edition, USK key, ObjectContainer objectContainer, ClientContext clientContext, boolean metadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo) {
- logger.log(Level.FINE, "Found USK update for Sone “%s” at %s.", new Object[] { sone, key });
+ logger.log(Level.FINE, "Found USK update for Sone “%s” at %s, new known good: %s, new slot too: %s.", new Object[] { sone, key, newKnownGood, newSlotToo });
if (newKnownGood) {
sone.updateUris(key.getURI());
+ soneDownloader.fetchSone(sone);
}
- soneDownloader.fetchSone(sone);
}
@Override
return;
}
try {
+ logger.log(Level.FINEST, "Unsubscribing from USK for %s…", new Object[] { sone });
node.clientCore.uskManager.unsubscribe(USK.create(sone.getRequestUri()), uskCallback);
} catch (MalformedURLException mue1) {
logger.log(Level.FINE, "Could not unsubscribe USK “" + sone.getRequestUri() + "”!", mue1);