Fix insertion logic.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 23 Oct 2010 22:45:07 +0000 (00:45 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 23 Oct 2010 22:45:07 +0000 (00:45 +0200)
src/main/java/net/pterodactylus/sone/core/SoneInserter.java

index 4bb4868..c2e0cc6 100644 (file)
@@ -116,9 +116,9 @@ public class SoneInserter extends AbstractService {
                                        lastModificationTime = System.currentTimeMillis();
                                        sone.setTime(lastModificationTime);
                                        logger.log(Level.FINE, "Sone %s has been modified, waiting 60 seconds before inserting.", new Object[] { sone.getName() });
-                                       if ((System.currentTimeMillis() - lastModificationTime) > (60 * 1000)) {
-                                               insertInformation = new InsertInformation(sone);
-                                       }
+                               }
+                               if ((lastModificationTime > 0) && ((System.currentTimeMillis() - lastModificationTime) > (60 * 1000))) {
+                                       insertInformation = new InsertInformation(sone);
                                }
                        }
 
@@ -148,6 +148,7 @@ public class SoneInserter extends AbstractService {
                                                        logger.log(Level.FINE, "Sone “%s” was not modified further, resetting counter…", new Object[] { sone });
                                                        sone.setModificationCounter(0);
                                                        modificationCounter = 0;
+                                                       lastModificationTime = 0;
                                                }
                                        }
                                }