forked from I2P_Developers/i2p.i2p
- Several plugin install fixes
- Remove unused UpdateTypes - Only try applicable updaters when updating - Javadoc fixes
This commit is contained in:
@ -133,8 +133,10 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
}
|
||||
PluginUpdateHandler puh = new PluginUpdateHandler(_context, this);
|
||||
register((Checker)puh, PLUGIN, HTTP, 0);
|
||||
register((Checker)puh, PLUGIN_INSTALL, HTTP, 0);
|
||||
register((Updater)puh, PLUGIN_INSTALL, HTTP, 0);
|
||||
register((Updater)puh, PLUGIN, HTTP, 0);
|
||||
// Don't do this until we can prevent it from retrying the same thing again...
|
||||
// handled inside P.U.H. for now
|
||||
//register((Updater)puh, PLUGIN, FILE, 0);
|
||||
new NewsTimerTask(_context, this);
|
||||
_context.simpleScheduler().addPeriodicEvent(new TaskCleaner(), TASK_CLEANER_TIME);
|
||||
}
|
||||
@ -414,15 +416,21 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
* @return true if task started
|
||||
*/
|
||||
public boolean installPlugin(String name, URI uri) {
|
||||
// We must have a name and install it in _available or else
|
||||
// update_fromCheck() will fail.
|
||||
// It's not removed from _available on success, as we lose the name.
|
||||
if (name == null)
|
||||
name = Long.toString(_context.random().nextLong());
|
||||
List<URI> uris = Collections.singletonList(uri);
|
||||
UpdateItem item = new UpdateItem(PLUGIN_INSTALL, name);
|
||||
VersionAvailable va = new VersionAvailable("", "", HTTP, uris);
|
||||
_available.putIfAbsent(item, va);
|
||||
UpdateItem item = new UpdateItem(PLUGIN, name);
|
||||
VersionAvailable va = _available.get(item);
|
||||
if (va == null) {
|
||||
va = new VersionAvailable("", "", HTTP, uris);
|
||||
_available.putIfAbsent(item, va);
|
||||
}
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Install plugin: " + name + ' ' + va);
|
||||
return update(PLUGIN_INSTALL, name);
|
||||
return update(PLUGIN, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -492,7 +500,11 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
_log.warn("No version available for: " + type + ' ' + id);
|
||||
return false;
|
||||
}
|
||||
List<RegisteredUpdater> sorted = new ArrayList(_registeredUpdaters);
|
||||
List<RegisteredUpdater> sorted = new ArrayList(4);
|
||||
for (RegisteredUpdater ru : _registeredUpdaters) {
|
||||
if (ru.type == type)
|
||||
sorted.add(ru);
|
||||
}
|
||||
Collections.sort(sorted);
|
||||
return retry(ui, va.sourceMap, sorted, maxTime) != null;
|
||||
}
|
||||
@ -573,7 +585,7 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
*
|
||||
* @param newsSource who told us
|
||||
* @param id plugin name for plugins, ignored otherwise
|
||||
* @param updateSourcew Where to get the new version
|
||||
* @param updateSources Where to get the new version
|
||||
* @param newVersion The new version available
|
||||
* @param minVersion The minimum installed version to be able to update to newVersion
|
||||
* @return true if it's newer
|
||||
@ -638,10 +650,8 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
// fall through
|
||||
|
||||
case ROUTER_SIGNED:
|
||||
case ROUTER_SIGNED_PACK200:
|
||||
if (shouldInstall() &&
|
||||
!(isUpdateInProgress(ROUTER_SIGNED) ||
|
||||
isUpdateInProgress(ROUTER_SIGNED_PACK200) ||
|
||||
isUpdateInProgress(ROUTER_UNSIGNED))) {
|
||||
update_fromCheck(type, id, DEFAULT_MAX_TIME);
|
||||
}
|
||||
@ -673,7 +683,6 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
switch (task.getType()) {
|
||||
case NEWS:
|
||||
case ROUTER_SIGNED:
|
||||
case ROUTER_SIGNED_PACK200:
|
||||
case ROUTER_UNSIGNED:
|
||||
// ConfigUpdateHandler, SummaryHelper, SummaryBarRenderer handle status display
|
||||
break;
|
||||
@ -766,8 +775,9 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
* If the return value is false, caller must call notifyTaskFailed() or notifyComplete()
|
||||
* again.
|
||||
*
|
||||
* @param must be an Updater, not a Checker
|
||||
* @param actualVersion may be higher (or lower?) than the version requested
|
||||
* @param file a valid format for the task's UpdateType
|
||||
* @param file a valid format for the task's UpdateType, or null if it did the installation itself
|
||||
* @return true if valid, false if corrupt
|
||||
*/
|
||||
public boolean notifyComplete(UpdateTask task, String actualVersion, File file) {
|
||||
@ -781,7 +791,6 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
break;
|
||||
|
||||
case ROUTER_SIGNED:
|
||||
case ROUTER_SIGNED_PACK200:
|
||||
rv = handleSudFile(task.getURI(), actualVersion, file);
|
||||
if (rv)
|
||||
notifyDownloaded(task.getType(), task.getID(), actualVersion);
|
||||
@ -795,12 +804,10 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
}
|
||||
break;
|
||||
|
||||
case PLUGIN:
|
||||
/// FIXME probably handled in PluginUpdateRunner??????????
|
||||
rv = handlePluginFile(task.getURI(), actualVersion, file);
|
||||
break;
|
||||
|
||||
default:
|
||||
case PLUGIN: // file handled in PluginUpdateRunner
|
||||
default: // assume Updater installed it
|
||||
rv = true;
|
||||
notifyInstalled(task.getType(), task.getID(), actualVersion);
|
||||
break;
|
||||
}
|
||||
if (rv)
|
||||
@ -881,7 +888,6 @@ public class ConsoleUpdateManager implements UpdateManager {
|
||||
break;
|
||||
|
||||
case ROUTER_SIGNED:
|
||||
case ROUTER_SIGNED_PACK200:
|
||||
String URLs = _context.getProperty(ConfigUpdateHandler.PROP_UPDATE_URL, ConfigUpdateHandler.DEFAULT_UPDATE_URL);
|
||||
StringTokenizer tok = new StringTokenizer(URLs, " ,\r\n");
|
||||
List<URI> rv = new ArrayList();
|
||||
|
@ -35,7 +35,7 @@ class NewsHandler extends UpdateHandler implements Checker {
|
||||
*/
|
||||
public UpdateTask check(UpdateType type, UpdateMethod method,
|
||||
String id, String currentVersion, long maxTime) {
|
||||
if ((type != ROUTER_SIGNED && type != ROUTER_SIGNED_PACK200 && type != NEWS) ||
|
||||
if ((type != ROUTER_SIGNED && type != NEWS) ||
|
||||
method != HTTP)
|
||||
return null;
|
||||
List<URI> updateSources = new ArrayList(2);
|
||||
|
@ -64,7 +64,7 @@ class PluginUpdateHandler implements Checker, Updater {
|
||||
@Override
|
||||
public UpdateTask update(UpdateType type, UpdateMethod method, List<URI> updateSources,
|
||||
String appName, String newVersion, long maxTime) {
|
||||
if ((type != UpdateType.PLUGIN && type != UpdateType.PLUGIN_INSTALL) ||
|
||||
if (type != UpdateType.PLUGIN ||
|
||||
method != UpdateMethod.HTTP || updateSources.isEmpty())
|
||||
return null;
|
||||
Properties props = PluginStarter.pluginProperties(_context, appName);
|
||||
|
@ -48,6 +48,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
private final URI _uri;
|
||||
private final String _xpi2pURL;
|
||||
private boolean _updated;
|
||||
private String _errMsg = "";
|
||||
|
||||
private static final String XPI2P = "app.xpi2p";
|
||||
private static final String ZIP = XPI2P + ".zip";
|
||||
@ -68,7 +69,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
|
||||
@Override
|
||||
public UpdateType getType() {
|
||||
return _oldVersion.equals("") ? UpdateType.PLUGIN_INSTALL : UpdateType.PLUGIN;
|
||||
return UpdateType.PLUGIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,7 +86,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
updateStatus("<b>" + _("Attempting to install from file {0}", _xpi2pURL) + "</b>");
|
||||
// strip off "file://"
|
||||
String xpi2pfile = _xpi2pURL.substring(7);
|
||||
if(xpi2pfile.length() == 0) { // This is actually what String.isEmpty() does, so it should be safe.
|
||||
if(xpi2pfile.length() == 0) {
|
||||
statusDone("<b>" + _("No file specified {0}", _xpi2pURL) + "</b>");
|
||||
} else {
|
||||
// copy the contents of from to _updateFile
|
||||
@ -114,8 +115,10 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
_log.error("Error downloading plugin", t);
|
||||
}
|
||||
}
|
||||
if (!_updated)
|
||||
_mgr.notifyTaskFailed(this, "", null);
|
||||
if (_updated)
|
||||
_mgr.notifyComplete(this, _newVersion, null);
|
||||
else
|
||||
_mgr.notifyTaskFailed(this, _errMsg, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -240,6 +243,9 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
statusDone("<b>" + _("Plugin {0} has mismatched versions", appName) + "</b>");
|
||||
return;
|
||||
}
|
||||
// set so notifyComplete() will work
|
||||
_appName = appName;
|
||||
_newVersion = version;
|
||||
|
||||
String minVersion = ConfigClientsHelper.stripHTML(props, "min-i2p-version");
|
||||
if (minVersion != null &&
|
||||
@ -414,6 +420,8 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
}
|
||||
|
||||
private void statusDone(String msg) {
|
||||
// if we fail, we will pass this back in notifyTaskFailed()
|
||||
_errMsg = msg;
|
||||
updateStatus(msg);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class UpdateHandler implements Updater {
|
||||
*/
|
||||
public UpdateTask update(UpdateType type, UpdateMethod method, List<URI> updateSources,
|
||||
String id, String newVersion, long maxTime) {
|
||||
if ((type != UpdateType.ROUTER_SIGNED && type != UpdateType.ROUTER_SIGNED_PACK200) ||
|
||||
if (type != UpdateType.ROUTER_SIGNED ||
|
||||
method != UpdateMethod.HTTP || updateSources.isEmpty())
|
||||
return null;
|
||||
UpdateRunner update = new UpdateRunner(_context, _mgr, updateSources);
|
||||
|
@ -151,13 +151,16 @@ public class PluginStarter implements Runnable {
|
||||
|
||||
if (log.shouldLog(Log.WARN))
|
||||
log.warn("Updating plugin: " + appName);
|
||||
// non-blocking
|
||||
mgr.update(PLUGIN, appName, 30*60*1000);
|
||||
int loop = 0;
|
||||
do {
|
||||
// only wait for 4 minutes, then we will
|
||||
// keep going
|
||||
try {
|
||||
Thread.sleep(5*1000);
|
||||
} catch (InterruptedException ie) {}
|
||||
if (loop++ > 40) break;
|
||||
if (loop++ > 48) break;
|
||||
} while (mgr.isUpdateInProgress(PLUGIN, appName));
|
||||
|
||||
if (mgr.getUpdateAvailable(PLUGIN, appName) != null)
|
||||
|
@ -416,7 +416,7 @@
|
||||
<group title="Core SDK (i2p.jar)" packages="net.i2p:net.i2p.*:net.i2p.client:net.i2p.client.*:net.i2p.internal:net.i2p.internal.*:freenet.support.CPUInformation:org.bouncycastle.oldcrypto:org.bouncycastle.oldcrypto.*:gnu.crypto.*:gnu.gettext:com.nettgryppa.security:net.metanotion:net.metanotion.*" />
|
||||
<group title="Streaming Library" packages="net.i2p.client.streaming" />
|
||||
<group title="Router" packages="net.i2p.router:net.i2p.router.*:net.i2p.data.i2np:org.cybergarage.*:org.freenetproject:org.xlattice.crypto.filters" />
|
||||
<group title="Router Console" packages="net.i2p.router.web" />
|
||||
<group title="Router Console" packages="net.i2p.router.web:net.i2p.router.update" />
|
||||
<!-- apps and bridges starting here, alphabetical please -->
|
||||
<group title="Addressbook Application" packages="net.i2p.addressbook" />
|
||||
<group title="BOB Bridge" packages="net.i2p.BOB" />
|
||||
|
@ -38,7 +38,7 @@ public interface UpdateManager {
|
||||
* @param newsSource who told us
|
||||
* @param id plugin name for plugins, ignored otherwise
|
||||
* @param method How to get the new version
|
||||
* @param updateSourcew Where to get the new version
|
||||
* @param updateSources Where to get the new version
|
||||
* @param newVersion The new version available
|
||||
* @param minVersion The minimum installed version to be able to update to newVersion
|
||||
* @return true if we didn't know already
|
||||
|
@ -6,11 +6,14 @@ package net.i2p.update;
|
||||
* @since 0.9.4
|
||||
*/
|
||||
public enum UpdateMethod {
|
||||
METHOD_DUMMY,
|
||||
METHOD_DUMMY, // Internal use only
|
||||
HTTP, // .i2p or via outproxy
|
||||
HTTP_CLEARNET, // direct non-.i2p
|
||||
HTTPS_CLEARNET, // direct non-.i2p
|
||||
TORRENT,
|
||||
GNUTELLA, IMULE, TAHOE_LAFS,
|
||||
DEBIAN
|
||||
GNUTELLA,
|
||||
IMULE,
|
||||
TAHOE_LAFS,
|
||||
DEBIAN,
|
||||
FILE // local file
|
||||
}
|
||||
|
@ -6,13 +6,14 @@ package net.i2p.update;
|
||||
* @since 0.9.4
|
||||
*/
|
||||
public enum UpdateType {
|
||||
TYPE_DUMMY,
|
||||
TYPE_DUMMY, // Internal use only
|
||||
NEWS,
|
||||
ROUTER_SIGNED,
|
||||
ROUTER_SIGNED_PACK200, // unused, use ROUTER_SIGNED for both
|
||||
ROUTER_UNSIGNED,
|
||||
PLUGIN, PLUGIN_INSTALL,
|
||||
GEOIP, BLOCKLIST, RESEED,
|
||||
PLUGIN,
|
||||
GEOIP,
|
||||
BLOCKLIST,
|
||||
RESEED,
|
||||
HOMEPAGE,
|
||||
ADDRESSBOOK
|
||||
}
|
||||
|
Reference in New Issue
Block a user