Don’t modify a Sone when the sone inserter was stopped before the insert finished.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 5 Nov 2010 14:02:25 +0000 (15:02 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 5 Nov 2010 14:02:25 +0000 (15:02 +0100)
src/main/java/net/pterodactylus/sone/core/SoneInserter.java

index 35910eb..5b281f6 100644 (file)
@@ -143,6 +143,11 @@ public class SoneInserter extends AbstractService {
                                try {
                                        core.setSoneStatus(sone, SoneStatus.inserting);
                                        FreenetURI finalUri = freenetInterface.insertDirectory(insertInformation.getInsertUri().setKeyType("USK").setSuggestedEdition(0), insertInformation.generateManifestEntries(), "index.html");
+                                       /* at this point we might already be stopped. */
+                                       if (shouldStop()) {
+                                               /* if so, bail out, don’t change anything. */
+                                               break;
+                                       }
                                        sone.setLatestEdition(finalUri.getEdition());
                                        success = true;
                                        logger.log(Level.INFO, "Inserted Sone “%s” at %s.", new Object[] { sone.getName(), finalUri });