Merge branch 'fcp-interface' into next
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneInserter.java
index 05fa4b4..0abebc3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * FreenetSone - SoneInserter.java - Copyright © 2010 David Roden
+ * Sone - SoneInserter.java - Copyright © 2010 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
@@ -160,7 +160,7 @@ public class SoneInserter extends AbstractService {
        protected void serviceRun() {
                long lastModificationTime = 0;
                String lastFingerprint = "";
-               while (!shouldStop()) {
+               while (!shouldStop()) { try {
                        /* check every seconds. */
                        sleep(1000);
 
@@ -229,14 +229,15 @@ public class SoneInserter extends AbstractService {
                                        synchronized (sone) {
                                                if (lastInsertFingerprint.equals(sone.getFingerprint())) {
                                                        logger.log(Level.FINE, "Sone “%s” was not modified further, resetting counter…", new Object[] { sone });
-                                                       core.saveSone(sone);
                                                        lastModificationTime = 0;
                                                        modified = false;
                                                }
                                        }
                                }
                        }
-               }
+               } catch (Throwable t1) {
+                       logger.log(Level.SEVERE, "SoneInserter threw an Exception!", t1);
+               }}
        }
 
        /**
@@ -246,7 +247,7 @@ public class SoneInserter extends AbstractService {
         *
         * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
         */
-       private static class InsertInformation {
+       private class InsertInformation {
 
                /** All properties of the Sone, copied for thread safety. */
                private final Map<String, Object> soneProperties = new HashMap<String, Object>();
@@ -345,6 +346,7 @@ public class SoneInserter extends AbstractService {
 
                        TemplateContext templateContext = templateContextFactory.createTemplateContext();
                        templateContext.set("currentSone", soneProperties);
+                       templateContext.set("currentEdition", core.getUpdateChecker().getLatestEdition());
                        templateContext.set("version", SonePlugin.VERSION);
                        StringWriter writer = new StringWriter();
                        StringBucket bucket = null;