X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FFreenetInterface.java;h=f5d7b665c53c852559bc783af8f9b22b08bef2e8;hb=b053038ea1d3479eb382ac87f467ce9efd5be0de;hp=30ba69a23e00f36e24de7b35a9e2d163cddb5a27;hpb=b29cf0908e6dfd2b55220a3a7e44200f2fe5b19e;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java index 30ba69a..f5d7b66 100644 --- a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java +++ b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java @@ -24,6 +24,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.util.collection.Pair; import net.pterodactylus.util.logging.Logging; import com.db4o.ObjectContainer; @@ -83,13 +84,13 @@ public class FreenetInterface { * The URI to fetch * @return The result of the fetch, or {@code null} if an error occured */ - public FetchResult fetchUri(FreenetURI uri) { + public Pair fetchUri(FreenetURI uri) { FetchResult fetchResult = null; FreenetURI currentUri = new FreenetURI(uri); while (true) { try { fetchResult = client.fetch(currentUri); - return fetchResult; + return new Pair(currentUri, fetchResult); } catch (FetchException fe1) { if (fe1.getMode() == FetchException.PERMANENT_REDIRECT) { currentUri = fe1.newURI; @@ -151,8 +152,14 @@ public class FreenetInterface { 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 known good: %s, new slot too: %s.", new Object[] { sone, key, newKnownGood, newSlotToo }); if (newKnownGood) { - sone.updateUris(key.suggestedEdition); - soneDownloader.fetchSone(sone); + sone.setLatestEdition(key.suggestedEdition); + new Thread(new Runnable() { + + @Override + public void run() { + soneDownloader.fetchSone(sone); + } + }, "Sone Downloader").start(); } }