prep for upcoming torrent updater
This commit is contained in:
@ -27,13 +27,13 @@ import net.i2p.util.Log;
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class UpdateHandler {
|
public class UpdateHandler {
|
||||||
private static UpdateRunner _updateRunner;
|
protected static UpdateRunner _updateRunner;
|
||||||
private RouterContext _context;
|
protected RouterContext _context;
|
||||||
private Log _log;
|
protected Log _log;
|
||||||
private DecimalFormat _pct = new DecimalFormat("00.0%");
|
protected DecimalFormat _pct = new DecimalFormat("00.0%");
|
||||||
|
|
||||||
private static final String SIGNED_UPDATE_FILE = "i2pupdate.sud";
|
protected static final String SIGNED_UPDATE_FILE = "i2pupdate.sud";
|
||||||
private static final String PROP_UPDATE_IN_PROGRESS = "net.i2p.router.web.UpdateHandler.updateInProgress";
|
protected static final String PROP_UPDATE_IN_PROGRESS = "net.i2p.router.web.UpdateHandler.updateInProgress";
|
||||||
|
|
||||||
public UpdateHandler() {
|
public UpdateHandler() {
|
||||||
this(ContextHelper.getContext(null));
|
this(ContextHelper.getContext(null));
|
||||||
@ -93,9 +93,8 @@ public class UpdateHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateRunner implements Runnable, EepGet.StatusListener {
|
public class UpdateRunner implements Runnable, EepGet.StatusListener {
|
||||||
private boolean _isRunning;
|
protected boolean _isRunning;
|
||||||
private String _status;
|
protected String _status;
|
||||||
private long _startedOn;
|
|
||||||
public UpdateRunner() {
|
public UpdateRunner() {
|
||||||
_isRunning = false;
|
_isRunning = false;
|
||||||
_status = "<b>Updating</b>";
|
_status = "<b>Updating</b>";
|
||||||
@ -108,8 +107,7 @@ public class UpdateHandler {
|
|||||||
System.setProperty(PROP_UPDATE_IN_PROGRESS, "false");
|
System.setProperty(PROP_UPDATE_IN_PROGRESS, "false");
|
||||||
_isRunning = false;
|
_isRunning = false;
|
||||||
}
|
}
|
||||||
private void update() {
|
protected void update() {
|
||||||
_startedOn = -1;
|
|
||||||
_status = "<b>Updating</b>";
|
_status = "<b>Updating</b>";
|
||||||
String updateURL = selectUpdateURL();
|
String updateURL = selectUpdateURL();
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
@ -130,7 +128,6 @@ public class UpdateHandler {
|
|||||||
else
|
else
|
||||||
get = new EepGet(_context, 1, SIGNED_UPDATE_FILE, updateURL, false);
|
get = new EepGet(_context, 1, SIGNED_UPDATE_FILE, updateURL, false);
|
||||||
get.addStatusListener(UpdateRunner.this);
|
get.addStatusListener(UpdateRunner.this);
|
||||||
_startedOn = _context.clock().now();
|
|
||||||
get.fetch();
|
get.fetch();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
_context.logManager().getLog(UpdateHandler.class).error("Error updating", t);
|
_context.logManager().getLog(UpdateHandler.class).error("Error updating", t);
|
||||||
|
Reference in New Issue
Block a user