X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=b929c233c68e480fdb516d6dac0f3effbe636db6;hb=44084738faad1c0c2609f332beef51feb148e66b;hp=284c6fb97ab803a8b31110c6d5b3366ef88b3f28;hpb=2c5b76a2fbce16ef33f079a3de9ae9fc9a9d30b8;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 284c6fb..b929c23 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -408,13 +408,22 @@ public class Core implements IdentityListener { return localSones.get(ownIdentity.getId()); } String latestEdition = ownIdentity.getProperty("Sone.LatestEdition"); - Sone sone = new Sone(ownIdentity).setInsertUri(getSoneUri(ownIdentity.getInsertUri(), latestEdition)).setRequestUri(getSoneUri(ownIdentity.getRequestUri(), latestEdition)); + final Sone sone = new Sone(ownIdentity).setInsertUri(getSoneUri(ownIdentity.getInsertUri(), latestEdition)).setRequestUri(getSoneUri(ownIdentity.getRequestUri(), latestEdition)); /* TODO - load posts ’n stuff */ localSones.put(ownIdentity.getId(), sone); SoneInserter soneInserter = new SoneInserter(this, freenetInterface, sone); soneInserters.put(sone, soneInserter); soneInserter.start(); setSoneStatus(sone, SoneStatus.idle); + new Thread(new Runnable() { + + @Override + @SuppressWarnings("synthetic-access") + public void run() { + soneDownloader.fetchSone(sone); + } + + }, "Sone Downloader").start(); return sone; } } @@ -498,7 +507,7 @@ public class Core implements IdentityListener { storedSone.setReplies(sone.getReplies()); storedSone.setLikePostIds(sone.getLikedPostIds()); storedSone.setLikeReplyIds(sone.getLikedReplyIds()); - storedSone.updateUris(sone.getRequestUri().getEdition()); + storedSone.setLatestEdition(sone.getRequestUri().getEdition()); } saveSone(storedSone); } @@ -538,7 +547,13 @@ public class Core implements IdentityListener { public void saveSone(Sone sone) { if (!isLocalSone(sone)) { logger.log(Level.FINE, "Tried to save non-local Sone: %s", sone); + return; + } + if (!(sone.getIdentity() instanceof OwnIdentity)) { + logger.log(Level.WARNING, "Local Sone without OwnIdentity found, refusing to save: %s", sone); + return; } + identityManager.setProperty((OwnIdentity) sone.getIdentity(), "Sone.LatestEdition", String.valueOf(sone.getLatestEdition())); /* TODO - implement saving. */ }