Don’t run background fetchers for Sones that are last updated more than 7 days ago.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Jan 2011 14:11:50 +0000 (15:11 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Jan 2011 14:11:50 +0000 (15:11 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/core/FreenetInterface.java
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java

index 60d334e..5da3bac 100644 (file)
@@ -1743,6 +1743,7 @@ public class Core implements IdentityListener, UpdateListener {
                        public void run() {
                                Sone sone = getRemoteSone(identity.getId());
                                sone.setIdentity(identity);
+                               soneDownloader.addSone(sone);
                                soneDownloader.fetchSone(sone);
                        }
                }).start();
index 3ccda5b..e22f407 100644 (file)
@@ -176,7 +176,7 @@ public class FreenetInterface {
                                }
                        };
                        soneUskCallbacks.put(sone.getId(), uskCallback);
-                       node.clientCore.uskManager.subscribe(USK.create(sone.getRequestUri()), uskCallback, true, (HighLevelSimpleClientImpl) client);
+                       node.clientCore.uskManager.subscribe(USK.create(sone.getRequestUri()), uskCallback, (System.currentTimeMillis() - sone.getTime()) < 7 * 24 * 60 * 60 * 1000, (HighLevelSimpleClientImpl) client);
                } catch (MalformedURLException mue1) {
                        logger.log(Level.WARNING, "Could not subscribe USK “" + sone.getRequestUri() + "”!", mue1);
                }
index 2eb4c71..177b462 100644 (file)
@@ -94,6 +94,7 @@ public class SoneDownloader extends AbstractService {
         */
        public void addSone(Sone sone) {
                if (sones.add(sone)) {
+                       freenetInterface.unregisterUsk(sone);
                        freenetInterface.registerUsk(sone, this);
                }
        }