I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit da4ea77c authored by zzz's avatar zzz
Browse files

more fixes

parent af4786ce
No related branches found
No related tags found
No related merge requests found
......@@ -106,14 +106,15 @@ public class ConsoleUpdateManager implements UpdateManager {
}
_context.registerUpdateManager(this);
Updater u = new DummyHandler(_context);
register(u, TYPE_DUMMY, HTTP, 0);
DummyHandler dh = new DummyHandler(_context);
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
// right at instantiation if the news is already indicating a new version
Checker c = new NewsHandler(_context);
register(c, NEWS, HTTP, 0);
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);
UnsignedUpdateHandler uuh = new UnsignedUpdateHandler(_context);
register((Checker)uuh, ROUTER_UNSIGNED, HTTP, 0);
......@@ -182,6 +183,14 @@ public class ConsoleUpdateManager implements UpdateManager {
return null;
}
/**
* Fire off a checker task
* Non-blocking.
*/
public void check(UpdateType type) {
check(type, "");
}
/**
* Fire off a checker task
* Non-blocking.
......@@ -645,7 +654,6 @@ public class ConsoleUpdateManager implements UpdateManager {
synchronized(task) {
task.notifyAll();
}
// TODO
}
public void notifyProgress(UpdateTask task, String status, long downloaded, long totalSize) {
......
......@@ -55,16 +55,22 @@ class NewsTimerTask implements SimpleTimer.TimedEvent {
public void timeReached() {
if (shouldFetchNews()) {
// blocking
fetchNews();
if (shouldFetchUnsigned())
fetchUnsignedHead();
if (shouldFetchUnsigned()) {
// 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() {
if (_context.router().gracefulShutdownInProgress())
return false;
if (NewsHelper.isUpdateInProgress())
if (_mgr.isCheckInProgress() || _mgr.isUpdateInProgress())
return false;
long lastFetch = NewsHelper.lastChecked(_context);
String freq = _context.getProperty(ConfigUpdateHandler.PROP_REFRESH_FREQUENCY,
......@@ -88,8 +94,9 @@ class NewsTimerTask implements SimpleTimer.TimedEvent {
}
}
/** blocking */
private void fetchNews() {
_mgr.check(NEWS, "");
_mgr.checkAvailable(NEWS, 60*1000);
}
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
* downloaded, as stored in the properties, then we download it using eepget.
*
* Non-blocking
*/
private void fetchUnsignedHead() {
_mgr.check(ROUTER_UNSIGNED, "");
_mgr.check(ROUTER_UNSIGNED);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment