forked from I2P_Developers/i2p.i2p
more fixes
This commit is contained in:
@ -106,14 +106,15 @@ public class ConsoleUpdateManager implements UpdateManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_context.registerUpdateManager(this);
|
_context.registerUpdateManager(this);
|
||||||
Updater u = new DummyHandler(_context);
|
DummyHandler dh = new DummyHandler(_context);
|
||||||
register(u, TYPE_DUMMY, HTTP, 0);
|
register((Checker)dh, TYPE_DUMMY, HTTP, 0);
|
||||||
|
register((Updater)dh, TYPE_DUMMY, HTTP, 0);
|
||||||
// register news before router, so we don't fire off an update
|
// register news before router, so we don't fire off an update
|
||||||
// right at instantiation if the news is already indicating a new version
|
// right at instantiation if the news is already indicating a new version
|
||||||
Checker c = new NewsHandler(_context);
|
Checker c = new NewsHandler(_context);
|
||||||
register(c, NEWS, HTTP, 0);
|
register(c, NEWS, HTTP, 0);
|
||||||
register(c, ROUTER_SIGNED, HTTP, 0); // news is an update checker for the router
|
register(c, ROUTER_SIGNED, HTTP, 0); // news is an update checker for the router
|
||||||
u = new UpdateHandler(_context);
|
Updater u = new UpdateHandler(_context);
|
||||||
register(u, ROUTER_SIGNED, HTTP, 0);
|
register(u, ROUTER_SIGNED, HTTP, 0);
|
||||||
UnsignedUpdateHandler uuh = new UnsignedUpdateHandler(_context);
|
UnsignedUpdateHandler uuh = new UnsignedUpdateHandler(_context);
|
||||||
register((Checker)uuh, ROUTER_UNSIGNED, HTTP, 0);
|
register((Checker)uuh, ROUTER_UNSIGNED, HTTP, 0);
|
||||||
@ -182,6 +183,14 @@ public class ConsoleUpdateManager implements UpdateManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire off a checker task
|
||||||
|
* Non-blocking.
|
||||||
|
*/
|
||||||
|
public void check(UpdateType type) {
|
||||||
|
check(type, "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fire off a checker task
|
* Fire off a checker task
|
||||||
* Non-blocking.
|
* Non-blocking.
|
||||||
@ -645,7 +654,6 @@ public class ConsoleUpdateManager implements UpdateManager {
|
|||||||
synchronized(task) {
|
synchronized(task) {
|
||||||
task.notifyAll();
|
task.notifyAll();
|
||||||
}
|
}
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyProgress(UpdateTask task, String status, long downloaded, long totalSize) {
|
public void notifyProgress(UpdateTask task, String status, long downloaded, long totalSize) {
|
||||||
|
@ -55,16 +55,22 @@ class NewsTimerTask implements SimpleTimer.TimedEvent {
|
|||||||
|
|
||||||
public void timeReached() {
|
public void timeReached() {
|
||||||
if (shouldFetchNews()) {
|
if (shouldFetchNews()) {
|
||||||
|
// blocking
|
||||||
fetchNews();
|
fetchNews();
|
||||||
if (shouldFetchUnsigned())
|
if (shouldFetchUnsigned()) {
|
||||||
fetchUnsignedHead();
|
// give it a sec for the download to kick in, if it's going to
|
||||||
|
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
|
||||||
|
if (!_mgr.isCheckInProgress() && !_mgr.isUpdateInProgress())
|
||||||
|
// nonblocking
|
||||||
|
fetchUnsignedHead();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldFetchNews() {
|
private boolean shouldFetchNews() {
|
||||||
if (_context.router().gracefulShutdownInProgress())
|
if (_context.router().gracefulShutdownInProgress())
|
||||||
return false;
|
return false;
|
||||||
if (NewsHelper.isUpdateInProgress())
|
if (_mgr.isCheckInProgress() || _mgr.isUpdateInProgress())
|
||||||
return false;
|
return false;
|
||||||
long lastFetch = NewsHelper.lastChecked(_context);
|
long lastFetch = NewsHelper.lastChecked(_context);
|
||||||
String freq = _context.getProperty(ConfigUpdateHandler.PROP_REFRESH_FREQUENCY,
|
String freq = _context.getProperty(ConfigUpdateHandler.PROP_REFRESH_FREQUENCY,
|
||||||
@ -88,8 +94,9 @@ class NewsTimerTask implements SimpleTimer.TimedEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** blocking */
|
||||||
private void fetchNews() {
|
private void fetchNews() {
|
||||||
_mgr.check(NEWS, "");
|
_mgr.checkAvailable(NEWS, 60*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldFetchUnsigned() {
|
private boolean shouldFetchUnsigned() {
|
||||||
@ -102,8 +109,10 @@ class NewsTimerTask implements SimpleTimer.TimedEvent {
|
|||||||
/**
|
/**
|
||||||
* HEAD the update url, and if the last-mod time is newer than the last update we
|
* HEAD the update url, and if the last-mod time is newer than the last update we
|
||||||
* downloaded, as stored in the properties, then we download it using eepget.
|
* downloaded, as stored in the properties, then we download it using eepget.
|
||||||
|
*
|
||||||
|
* Non-blocking
|
||||||
*/
|
*/
|
||||||
private void fetchUnsignedHead() {
|
private void fetchUnsignedHead() {
|
||||||
_mgr.check(ROUTER_UNSIGNED, "");
|
_mgr.check(ROUTER_UNSIGNED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user