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