forked from I2P_Developers/i2p.i2p
Update: Preliminary work for su3 router updates:
- new ROUTER_SIGNED_SU3 UpdateType - Add support for torrent and HTTP - Refactor UpdateRunners to return actual UpdateType - Deal with signed/su3 conflicts - unpack/verify stubbed only
This commit is contained in:
@ -49,7 +49,7 @@ class NewsFetcher extends UpdateRunner {
|
||||
private static final String TEMP_NEWS_FILE = "news.xml.temp";
|
||||
|
||||
public NewsFetcher(RouterContext ctx, ConsoleUpdateManager mgr, List<URI> uris) {
|
||||
super(ctx, mgr, uris);
|
||||
super(ctx, mgr, NEWS, uris);
|
||||
_newsFile = new File(ctx.getRouterDir(), NewsHelper.NEWS_FILE);
|
||||
_tempFile = new File(ctx.getTempDir(), "tmp-" + ctx.random().nextLong() + TEMP_NEWS_FILE);
|
||||
long lastMod = NewsHelper.lastChecked(ctx);
|
||||
@ -57,9 +57,6 @@ class NewsFetcher extends UpdateRunner {
|
||||
_lastModified = RFC822Date.to822Date(lastMod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateType getType() { return NEWS; }
|
||||
|
||||
private boolean dontInstall() {
|
||||
return NewsHelper.dontInstall(_context);
|
||||
}
|
||||
@ -114,6 +111,7 @@ class NewsFetcher extends UpdateRunner {
|
||||
private static final String MIN_VERSION_KEY = "minversion";
|
||||
private static final String SUD_KEY = "sudtorrent";
|
||||
private static final String SU2_KEY = "su2torrent";
|
||||
private static final String SU3_KEY = "su3torrent";
|
||||
private static final String CLEARNET_SUD_KEY = "sudclearnet";
|
||||
private static final String CLEARNET_SU2_KEY = "su2clearnet";
|
||||
private static final String I2P_SUD_KEY = "sudi2p";
|
||||
@ -149,6 +147,23 @@ class NewsFetcher extends UpdateRunner {
|
||||
// and look for a second entry with clearnet URLs
|
||||
// TODO clearnet URLs, notify with HTTP_CLEARNET and/or HTTPS_CLEARNET
|
||||
Map<UpdateMethod, List<URI>> sourceMap = new HashMap(4);
|
||||
// Must do su3 first
|
||||
if (ConfigUpdateHandler.USE_SU3_UPDATE) {
|
||||
sourceMap.put(HTTP, _mgr.getUpdateURLs(ROUTER_SIGNED_SU3, "", HTTP));
|
||||
String murl = args.get(SU3_KEY);
|
||||
if (murl != null) {
|
||||
List<URI> uris = tokenize(murl);
|
||||
if (!uris.isEmpty()) {
|
||||
Collections.shuffle(uris, _context.random());
|
||||
sourceMap.put(TORRENT, uris);
|
||||
}
|
||||
}
|
||||
// notify about all sources at once
|
||||
_mgr.notifyVersionAvailable(this, _currentURI, ROUTER_SIGNED_SU3,
|
||||
"", sourceMap, ver, "");
|
||||
sourceMap.clear();
|
||||
}
|
||||
// now do sud/su2
|
||||
sourceMap.put(HTTP, _mgr.getUpdateURLs(ROUTER_SIGNED, "", HTTP));
|
||||
String key = FileUtil.isPack200Supported() ? SU2_KEY : SUD_KEY;
|
||||
String murl = args.get(key);
|
||||
@ -160,9 +175,8 @@ class NewsFetcher extends UpdateRunner {
|
||||
}
|
||||
}
|
||||
// notify about all sources at once
|
||||
_mgr.notifyVersionAvailable(this, _currentURI,
|
||||
ROUTER_SIGNED, "", sourceMap,
|
||||
ver, "");
|
||||
_mgr.notifyVersionAvailable(this, _currentURI, ROUTER_SIGNED,
|
||||
"", sourceMap, ver, "");
|
||||
} else {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Our version is current");
|
||||
|
Reference in New Issue
Block a user