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