X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneRescuer.java;h=60451274548b77f5b6ace075db02aba46a01ea44;hb=b7f0567e2a3e88f2327dfdb045a1b0e4bca9dcac;hp=542ec4aa69596c609af5d0159afa56ca77641016;hpb=1bc78b582ac59f2438002997f5780db4dcee0a2a;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java b/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java index 542ec4a..6045127 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java @@ -1,5 +1,5 @@ /* - * Sone - SoneRescuer.java - Copyright © 2011 David Roden + * Sone - SoneRescuer.java - Copyright © 2011–2019 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,6 @@ import freenet.keys.FreenetURI; /** * The Sone rescuer downloads older editions of a Sone and updates the currently * stored Sone with it. - * - * @author David ‘Bombe’ Roden */ public class SoneRescuer extends AbstractService { @@ -74,6 +72,7 @@ public class SoneRescuer extends AbstractService { * * @return {@code true} if the Sone rescuer is currently fetching a Sone */ + @SuppressWarnings("unused") // used in rescue.html public boolean isFetching() { return fetching; } @@ -83,6 +82,7 @@ public class SoneRescuer extends AbstractService { * * @return The edition that is currently being downloaded */ + @SuppressWarnings("unused") // used in rescue.html public long getCurrentEdition() { return currentEdition; } @@ -102,28 +102,18 @@ public class SoneRescuer extends AbstractService { * * @return The next edition the Sone rescuer can download */ + @SuppressWarnings("unused") // used in rescue.html public long getNextEdition() { return currentEdition - 1; } /** - * Sets the edition to rescue. - * - * @param edition - * The edition to rescue - * @return This Sone rescuer - */ - public SoneRescuer setEdition(long edition) { - currentEdition = edition; - return this; - } - - /** * Sets whether the last fetch was successful. * * @return {@code true} if the last fetch was successful, {@code false} * otherwise */ + @SuppressWarnings("unused") // used in rescue.html public boolean isLastFetchSuccessful() { return lastFetchSuccessful; } @@ -133,15 +123,22 @@ public class SoneRescuer extends AbstractService { // /** - * Starts the next fetch. If you want to fetch a different edition than “the - * next older one,” remember to call {@link #setEdition(long)} before - * calling this method. + * Starts the next fetch. */ public void startNextFetch() { fetching = true; notifySyncObject(); } + /** + * Starts the next fetch. + */ + public void startNextFetchWithSkip() { + currentEdition--; + fetching = true; + notifySyncObject(); + } + // // SERVICE METHODS // @@ -157,13 +154,14 @@ public class SoneRescuer extends AbstractService { } if (fetching) { core.lockSone(sone); - FreenetURI soneUri = sone.getRequestUri().setKeyType("SSK").setDocName("Sone-" + currentEdition).setMetaString(new String[] { "sone.xml" }); + FreenetURI soneUri = sone.getRequestUri().setKeyType("SSK").setDocName("Sone-" + getNextEdition()).setMetaString(new String[] { "sone.xml" }); System.out.println("URI: " + soneUri); Sone fetchedSone = soneDownloader.fetchSone(sone, soneUri, true); System.out.println("Sone: " + fetchedSone); lastFetchSuccessful = (fetchedSone != null); if (lastFetchSuccessful) { core.updateSone(fetchedSone, true); + currentEdition = getNextEdition(); } fetching = false; }