Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the update key is changed, subscribe to the new key. #964

Open
wants to merge 7 commits into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/freenet/node/updater/NodeUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ public abstract class NodeUpdater implements ClientGetCallback, USKCallback, Req
}

void start() {
subscribe(() -> manager.blow("The auto-update URI isn't valid and can't be used", true));
}

private void subscribe(Runnable onError) {
try {
// because of UoM, this version is actually worth having as well
USK myUsk = USK.create(URI.setSuggestedEdition(currentVersion));
core.getUskManager().subscribe(myUsk, this, true, getRequestClient());
} catch(MalformedURLException e) {
} catch (MalformedURLException e) {
Logger.error(this, "The auto-update URI isn't valid and can't be used");
manager.blow("The auto-update URI isn't valid and can't be used", true);
onError.run();
}
}

Expand Down Expand Up @@ -511,8 +515,9 @@ public synchronized boolean canUpdateNow() {
/** Called when the fetch URI has changed. No major locks are held by caller.
* @param uri The new URI. */
public void onChangeURI(FreenetURI uri) {
kill();
kill(); // unsubscribes from the old uri
this.URI = uri;
subscribe(() -> {});
maybeUpdate();
}

Expand Down