forked from I2P_Developers/i2p.i2p
- Fix spacing in summary bar
- Add start() in UpdateTask so things happen in the right order - Add toString() in UpdateTask for better debugging - Fix getID() for plugin UpdateTasks
This commit is contained in:
@ -47,7 +47,6 @@ class UpdateHandler implements Updater {
|
||||
return null;
|
||||
UpdateRunner update = new UpdateRunner(_context, _umgr, _smgr, updateSources, newVersion);
|
||||
_umgr.notifyProgress(update, "<b>" + _smgr.util().getString("Updating") + "</b>");
|
||||
update.start();
|
||||
return update;
|
||||
}
|
||||
}
|
||||
|
@ -77,11 +77,6 @@ class UpdateRunner implements UpdateTask, CompleteListener {
|
||||
* If it is, get the whole thing.
|
||||
*/
|
||||
private void update() {
|
||||
if (_urls.isEmpty()) {
|
||||
_umgr.notifyTaskFailed(this, "", null);
|
||||
return;
|
||||
}
|
||||
|
||||
for (URI uri : _urls) {
|
||||
_currentURI = uri;
|
||||
String updateURL = uri.toString();
|
||||
@ -102,7 +97,9 @@ class UpdateRunner implements UpdateTask, CompleteListener {
|
||||
new Timeout();
|
||||
break;
|
||||
}
|
||||
} catch (IllegalArgumentException iae) {}
|
||||
} catch (IllegalArgumentException iae) {
|
||||
_log.error("Invalid update URL", iae);
|
||||
}
|
||||
}
|
||||
if (_snark == null)
|
||||
fatal("No valid URLs");
|
||||
@ -232,4 +229,9 @@ class UpdateRunner implements UpdateTask, CompleteListener {
|
||||
private void updateStatus(String s) {
|
||||
_umgr.notifyProgress(this, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ' ' + getType() + ' ' + getID() + ' ' + getMethod() + ' ' + getURI();
|
||||
}
|
||||
}
|
||||
|
@ -184,6 +184,7 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Starting " + r);
|
||||
_activeCheckers.add(t);
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
if (t != null) {
|
||||
@ -226,6 +227,7 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Starting " + r);
|
||||
_activeCheckers.add(t);
|
||||
t.start();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -517,6 +519,7 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Starting " + r);
|
||||
_downloaders.put(t, toTry);
|
||||
t.start();
|
||||
return t;
|
||||
} else {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
|
@ -46,7 +46,6 @@ class NewsHandler extends UpdateHandler implements Checker {
|
||||
updateSources.add(new URI(BACKUP_NEWS_URL));
|
||||
} catch (URISyntaxException use) {}
|
||||
UpdateRunner update = new NewsFetcher(_context, _mgr, updateSources);
|
||||
update.start();
|
||||
return update;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ class PluginUpdateChecker extends UpdateRunner {
|
||||
@Override
|
||||
public UpdateType getType() { return UpdateType.PLUGIN; }
|
||||
|
||||
@Override
|
||||
public String getID() { return _appName; }
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
_isRunning = true;
|
||||
|
@ -57,7 +57,6 @@ class PluginUpdateHandler implements Checker, Updater {
|
||||
}
|
||||
|
||||
UpdateRunner update = new PluginUpdateChecker(_context, _mgr, updateSources, appName, oldVersion);
|
||||
update.start();
|
||||
return update;
|
||||
}
|
||||
|
||||
@ -78,7 +77,6 @@ class PluginUpdateHandler implements Checker, Updater {
|
||||
UpdateRunner update = new PluginUpdateRunner(_context, _mgr, updateSources, appName, oldVersion);
|
||||
// set status before thread to ensure UI feedback
|
||||
_mgr.notifyProgress(update, "<b>" + _mgr._("Updating") + "</b>");
|
||||
update.start();
|
||||
return update;
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,9 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
@Override
|
||||
public URI getURI() { return _uri; }
|
||||
|
||||
@Override
|
||||
public String getID() { return _appName; }
|
||||
|
||||
@Override
|
||||
protected void update() {
|
||||
|
||||
|
@ -71,7 +71,6 @@ class UnsignedUpdateHandler implements Checker, Updater {
|
||||
}
|
||||
|
||||
UpdateRunner update = new UnsignedUpdateChecker(_context, _mgr, updateSources, ms);
|
||||
update.start();
|
||||
return update;
|
||||
}
|
||||
|
||||
@ -91,7 +90,6 @@ class UnsignedUpdateHandler implements Checker, Updater {
|
||||
UpdateRunner update = new UnsignedUpdateRunner(_context, _mgr, updateSources);
|
||||
// set status before thread to ensure UI feedback
|
||||
_mgr.notifyProgress(update, "<b>" + _mgr._("Updating") + "</b>");
|
||||
update.start();
|
||||
return update;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ class UpdateHandler implements Updater {
|
||||
UpdateRunner update = new UpdateRunner(_context, _mgr, updateSources);
|
||||
// set status before thread to ensure UI feedback
|
||||
_mgr.notifyProgress(update, "<b>" + _mgr._("Updating") + "</b>");
|
||||
update.start();
|
||||
return update;
|
||||
}
|
||||
}
|
||||
|
@ -236,4 +236,9 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
||||
protected String _(String s, Object o) {
|
||||
return _mgr._(s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ' ' + getType() + ' ' + getID() + ' ' + getMethod() + ' ' + getURI();
|
||||
}
|
||||
}
|
||||
|
@ -652,8 +652,10 @@ public class SummaryHelper extends HelperBase {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
// display all the time so we display the final failure message, and plugin update messages too
|
||||
String status = NewsHelper.getUpdateStatus();
|
||||
boolean needSpace = false;
|
||||
if (status.length() > 0) {
|
||||
buf.append("<h4>").append(status).append("</h4>\n");
|
||||
needSpace = true;
|
||||
}
|
||||
String dver = NewsHelper.updateVersionDownloaded();
|
||||
if (dver == null)
|
||||
@ -661,6 +663,10 @@ public class SummaryHelper extends HelperBase {
|
||||
if (dver != null &&
|
||||
!NewsHelper.isUpdateInProgress() &&
|
||||
!_context.router().gracefulShutdownInProgress()) {
|
||||
if (needSpace)
|
||||
buf.append("<hr>");
|
||||
else
|
||||
needSpace = true;
|
||||
buf.append("<h4><b>").append(_("Update downloaded")).append("<br>");
|
||||
if (_context.hasWrapper())
|
||||
buf.append(_("Click Restart to install"));
|
||||
@ -675,6 +681,8 @@ public class SummaryHelper extends HelperBase {
|
||||
_context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY) > 0 && // assume using proxy for now
|
||||
getAction() == null &&
|
||||
getUpdateNonce() == null) {
|
||||
if (needSpace)
|
||||
buf.append("<hr>");
|
||||
long nonce = _context.random().nextLong();
|
||||
String prev = System.getProperty("net.i2p.router.web.UpdateHandler.nonce");
|
||||
if (prev != null)
|
||||
|
@ -9,6 +9,11 @@ import java.net.URI;
|
||||
*/
|
||||
public interface UpdateTask {
|
||||
|
||||
/**
|
||||
* Tasks must not start themselves in the constructor. Do it here.
|
||||
*/
|
||||
public void start();
|
||||
|
||||
public void shutdown();
|
||||
|
||||
public boolean isRunning();
|
||||
|
Reference in New Issue
Block a user