Use local Sone in Sone inserter.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneInserter.java
index c38e495..5ae2f73 100644 (file)
@@ -39,6 +39,7 @@ import net.pterodactylus.sone.core.event.SoneInsertAbortedEvent;
 import net.pterodactylus.sone.core.event.SoneInsertedEvent;
 import net.pterodactylus.sone.core.event.SoneInsertingEvent;
 import net.pterodactylus.sone.data.Album;
+import net.pterodactylus.sone.data.LocalSone;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
@@ -120,7 +121,7 @@ public class SoneInserter extends AbstractService {
                this(core, eventBus, freenetInterface, soneId, new SoneModificationDetector(new LockableFingerprintProvider() {
                        @Override
                        public boolean isLocked() {
-                               final Optional<Sone> sone = core.getSone(soneId);
+                               final Optional<LocalSone> sone = core.getLocalSone(soneId);
                                if (!sone.isPresent()) {
                                        return false;
                                }
@@ -214,12 +215,12 @@ public class SoneInserter extends AbstractService {
                                sleep(delay);
 
                                if (soneModificationDetector.isEligibleForInsert()) {
-                                       Optional<Sone> soneOptional = core.getSone(soneId);
+                                       Optional<LocalSone> soneOptional = core.getLocalSone(soneId);
                                        if (!soneOptional.isPresent()) {
                                                logger.log(Level.WARNING, format("Sone %s has disappeared, exiting inserter.", soneId));
                                                return;
                                        }
-                                       Sone sone = soneOptional.get();
+                                       LocalSone sone = soneOptional.get();
                                        InsertInformation insertInformation = new InsertInformation(sone);
                                        logger.log(Level.INFO, String.format("Inserting Sone “%s”…", sone.getName()));
 
@@ -229,7 +230,7 @@ public class SoneInserter extends AbstractService {
                                                long insertTime = currentTimeMillis();
                                                eventBus.post(new SoneInsertingEvent(sone));
                                                FreenetURI finalUri = freenetInterface.insertDirectory(sone.getInsertUri(), insertInformation.generateManifestEntries(), "index.html");
-                                               eventBus.post(new SoneInsertedEvent(sone, currentTimeMillis() - insertTime));
+                                               eventBus.post(new SoneInsertedEvent(sone, currentTimeMillis() - insertTime, insertInformation.getFingerprint()));
                                                /* at this point we might already be stopped. */
                                                if (shouldStop()) {
                                                        /* if so, bail out, don’t change anything. */