X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FFreenetInterface.java;h=b0c108ab582ba2e1aa1db0f12464907cbab96c93;hb=40a1ac4c90c1480936c9c782727209cf23acd5e5;hp=9ccf5fc0bc1ff6515da4adb459be185368507184;hpb=916a38a274bcddc755c06fe21bdbc41d494b1825;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 9ccf5fc..b0c108a 100644 --- a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java +++ b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java @@ -39,6 +39,7 @@ import com.db4o.ObjectContainer; import com.google.common.base.Function; import com.google.common.eventbus.EventBus; import com.google.inject.Inject; +import com.google.inject.Singleton; import freenet.client.ClientMetadata; import freenet.client.FetchException; @@ -66,6 +67,7 @@ import freenet.support.io.ArrayBucket; * * @author David ‘Bombe’ Roden */ +@Singleton public class FreenetInterface { /** The logger. */ @@ -180,16 +182,7 @@ public class FreenetInterface { } } - /** - * Registers the USK for the given Sone and notifies the given - * {@link SoneDownloader} if an update was found. - * - * @param sone - * The Sone to watch - * @param soneDownloader - * The Sone download to notify on updates - */ - public void registerUsk(final Sone sone, final SoneDownloader soneDownloader) { + public void registerUsk(final Sone sone, final SoneUpdater soneUpdater) { try { logger.log(Level.FINE, String.format("Registering Sone “%s” for USK updates at %s…", sone, sone.getRequestUri().setMetaString(new String[] { "sone.xml" }))); USKCallback uskCallback = new USKCallback() { @@ -198,16 +191,7 @@ public class FreenetInterface { @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, String.format("Found USK update for Sone “%s” at %s, new known good: %s, new slot too: %s.", sone, key, newKnownGood, newSlotToo)); - if (edition > sone.getLatestEdition()) { - sone.setLatestEdition(edition); - new Thread(new Runnable() { - - @Override - public void run() { - soneDownloader.fetchSone(sone); - } - }, "Sone Downloader").start(); - } + soneUpdater.updateSone(sone, edition); } @Override