πŸ”€ Merge branch 'release/v82'
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneRescuer.java
index adc0925..2a1d14d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - SoneRescuer.java - Copyright Β© 2011–2019 David Roden
+ * Sone - SoneRescuer.java - Copyright Β© 2011–2020 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
@@ -108,6 +108,18 @@ public class SoneRescuer extends AbstractService {
        }
 
        /**
+        * 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}
@@ -123,7 +135,9 @@ public class SoneRescuer extends AbstractService {
        //
 
        /**
-        * Starts the next fetch.
+        * 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.
         */
        public void startNextFetch() {
                fetching = true;
@@ -145,14 +159,13 @@ public class SoneRescuer extends AbstractService {
                        }
                        if (fetching) {
                                core.lockSone(sone);
-                               FreenetURI soneUri = sone.getRequestUri().setKeyType("SSK").setDocName("Sone-" + getNextEdition()).setMetaString(new String[] { "sone.xml" });
+                               FreenetURI soneUri = sone.getRequestUri().setKeyType("SSK").setDocName("Sone-" + currentEdition).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;
                        }