From: David ‘Bombe’ Roden Date: Sat, 19 Oct 2013 14:43:58 +0000 (+0200) Subject: Restore the actual purpose of the code. X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=ee1e4a2f7a24a97270a7c93570a984b3a0b9cf6c Restore the actual purpose of the code. --- 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) {