From bac4af4ce1b76a3a2f399dff441684e4268da60c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 11 Jun 2014 06:34:58 +0200 Subject: [PATCH] =?utf8?q?Remove=20=E2=80=9Cmodified=E2=80=9D=20flag,=20it?= =?utf8?q?=E2=80=99s=20now=20calculated=20on-the-fly.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/core/SoneInserter.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index d8564ba..d9235fd 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -99,9 +99,6 @@ public class SoneInserter extends AbstractService { /** The Sone to insert. */ private volatile Sone sone; - /** Whether a modification has been detected. */ - private volatile boolean modified = false; - /** The fingerprint of the last insert. */ private volatile String lastInsertFingerprint; @@ -180,7 +177,7 @@ public class SoneInserter extends AbstractService { * otherwise */ public boolean isModified() { - return modified; + return !lastInsertFingerprint.equals(sone.getFingerprint()); } // @@ -204,9 +201,6 @@ public class SoneInserter extends AbstractService { Sone sone = this.sone; if (core.isLocked(sone)) { /* trigger redetection when the Sone is unlocked. */ - synchronized (sone) { - modified = !sone.getFingerprint().equals(lastInsertedFingerprint); - } lastFingerprint = ""; lastModificationTime = absent(); continue; @@ -217,17 +211,15 @@ public class SoneInserter extends AbstractService { String fingerprint = sone.getFingerprint(); if (!fingerprint.equals(lastFingerprint)) { if (fingerprint.equals(lastInsertedFingerprint)) { - modified = false; lastModificationTime = absent(); logger.log(Level.FINE, String.format("Sone %s has been reverted to last insert state.", sone)); } else { lastModificationTime = of(currentTimeMillis()); - modified = true; logger.log(Level.FINE, String.format("Sone %s has been modified, waiting %d seconds before inserting.", sone.getName(), insertionDelay)); } lastFingerprint = fingerprint; } - if (modified && lastModificationTime.isPresent() && ((currentTimeMillis() - lastModificationTime.get()) > (insertionDelay * 1000))) { + if (lastModificationTime.isPresent() && ((currentTimeMillis() - lastModificationTime.get()) > (insertionDelay * 1000))) { lastInsertedFingerprint = fingerprint; insertSoneNow = true; } @@ -273,7 +265,6 @@ public class SoneInserter extends AbstractService { lastModificationTime = absent(); lastInsertFingerprint = insertInformation.getFingerprint(); core.touchConfiguration(); - modified = false; } } } -- 2.7.4