Download remote Sones first thing after adding them.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 4 Nov 2010 21:43:55 +0000 (22:43 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 4 Nov 2010 21:43:55 +0000 (22:43 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java

index 265b8e1..d63b938 100644 (file)
@@ -489,14 +489,23 @@ public class Core implements IdentityListener {
                        return null;
                }
                synchronized (remoteSones) {
+                       final Sone sone = getRemoteSone(identity.getId()).setIdentity(identity);
                        if (remoteSones.containsKey(identity.getId())) {
                                logger.log(Level.FINE, "Identity already exists: %s", identity);
                                return remoteSones.get(identity.getId());
                        }
-                       Sone sone = new Sone(identity);
                        sone.setRequestUri(getSoneUri(identity.getRequestUri(), identity.getProperty("Sone.LatestEdition")));
                        remoteSones.put(identity.getId(), sone);
                        soneDownloader.addSone(sone);
+                       new Thread(new Runnable() {
+
+                               @Override
+                               @SuppressWarnings("synthetic-access")
+                               public void run() {
+                                       soneDownloader.fetchSone(sone);
+                               }
+
+                       }, "Sone Downloader").start();
                        setSoneStatus(sone, SoneStatus.idle);
                        return sone;
                }