From ee1e4a2f7a24a97270a7c93570a984b3a0b9cf6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 19 Oct 2013 16:43:58 +0200 Subject: [PATCH] Restore the actual purpose of the code. --- src/main/java/net/pterodactylus/sone/core/Core.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 63bf181..612398d 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -616,11 +616,12 @@ public class Core extends AbstractService implements SoneProvider { return null; } synchronized (sones) { - final Sone sone = database.newSoneBuilder().by(identity.getId()).build(Optional.absent()); - if (sone.isLocal()) { - return sone; + Optional existingSone = database.getSone(identity.getId()); + if (existingSone.isPresent() && existingSone.get().isLocal()) { + return existingSone.get(); } - boolean newSone = sone.getRequestUri() == null; + boolean newSone = !existingSone.isPresent(); + final Sone sone = newSone ? database.newSoneBuilder().by(identity.getId()).build(Optional.absent()) : existingSone.get(); sone.setRequestUri(SoneUri.create(identity.getRequestUri())); sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), (long) 0)); if (newSone) { -- 2.7.4