From: David ‘Bombe’ Roden Date: Mon, 7 Nov 2011 05:16:35 +0000 (+0100) Subject: Prevent the insert fingerprint from being stored until the insert is finished. X-Git-Tag: 0.7.3^2~16 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7c46bb9df49aadd0f41c5ac229994d3df8a2a5d4;p=Sone.git Prevent the insert fingerprint from being stored until the insert is finished. --- diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index eb74dc0..4d9878f 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -190,6 +190,7 @@ public class SoneInserter extends AbstractService { @Override protected void serviceRun() { long lastModificationTime = 0; + String lastInsertedFingerprint = lastInsertFingerprint; String lastFingerprint = ""; while (!shouldStop()) { try { /* check every seconds. */ @@ -199,7 +200,7 @@ public class SoneInserter extends AbstractService { if (core.isLocked(sone)) { /* trigger redetection when the Sone is unlocked. */ synchronized (sone) { - modified = !sone.getFingerprint().equals(lastInsertFingerprint); + modified = !sone.getFingerprint().equals(lastInsertedFingerprint); } lastFingerprint = ""; lastModificationTime = 0; @@ -210,7 +211,7 @@ public class SoneInserter extends AbstractService { synchronized (sone) { String fingerprint = sone.getFingerprint(); if (!fingerprint.equals(lastFingerprint)) { - if (fingerprint.equals(lastInsertFingerprint)) { + if (fingerprint.equals(lastInsertedFingerprint)) { modified = false; lastModificationTime = 0; logger.log(Level.FINE, "Sone %s has been reverted to last insert state.", sone); @@ -222,7 +223,7 @@ public class SoneInserter extends AbstractService { lastFingerprint = fingerprint; } if (modified && (lastModificationTime > 0) && ((System.currentTimeMillis() - lastModificationTime) > (insertionDelay * 1000))) { - lastInsertFingerprint = fingerprint; + lastInsertedFingerprint = fingerprint; insertInformation = new InsertInformation(sone); } } @@ -261,9 +262,11 @@ public class SoneInserter extends AbstractService { */ if (success) { synchronized (sone) { - if (lastInsertFingerprint.equals(sone.getFingerprint())) { + if (lastInsertedFingerprint.equals(sone.getFingerprint())) { logger.log(Level.FINE, "Sone “%s” was not modified further, resetting counter…", new Object[] { sone }); lastModificationTime = 0; + lastInsertFingerprint = lastInsertedFingerprint; + core.touchConfiguration(); modified = false; } }