forked from I2P_Developers/i2p.i2p
Plugins: Add form to browse for local plugin file to install,
easy since we have multipart in console now Better status feedback from update manager to console
This commit is contained in:
@ -188,6 +188,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
|
||||
PluginUpdateHandler puh = new PluginUpdateHandler(_context, this);
|
||||
register((Checker)puh, PLUGIN, HTTP, 0);
|
||||
register((Updater)puh, PLUGIN, HTTP, 0);
|
||||
register((Updater)puh, PLUGIN, FILE, 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);
|
||||
@ -523,7 +524,8 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
|
||||
UpdateItem item = new UpdateItem(PLUGIN, name);
|
||||
VersionAvailable va = _available.get(item);
|
||||
if (va == null) {
|
||||
va = new VersionAvailable("", "", HTTP, uris);
|
||||
UpdateMethod method = "file".equals(uri.getScheme()) ? FILE : HTTP;
|
||||
va = new VersionAvailable("", "", method, uris);
|
||||
_available.putIfAbsent(item, va);
|
||||
}
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
@ -971,8 +973,8 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
|
||||
* @param t may be null
|
||||
*/
|
||||
public void notifyTaskFailed(UpdateTask task, String reason, Throwable t) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Failed " + task + " for " + task.getType() + ": " + reason, t);
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Failed " + task + " for " + task.getType() + ": " + reason, t);
|
||||
List<RegisteredUpdater> toTry = _downloaders.get(task);
|
||||
if (toTry != null) {
|
||||
UpdateItem ui = new UpdateItem(task.getType(), task.getID());
|
||||
@ -988,8 +990,27 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
|
||||
_downloaders.remove(task);
|
||||
_activeCheckers.remove(task);
|
||||
// any other types that shouldn't display?
|
||||
if (task.getURI() != null && task.getType() != TYPE_DUMMY)
|
||||
finishStatus("<b>" + _("Transfer failed from {0}", linkify(task.getURI().toString())) + "</b>");
|
||||
if (task.getURI() != null && task.getType() != TYPE_DUMMY) {
|
||||
StringBuilder buf = new StringBuilder(256);
|
||||
buf.append("<b>");
|
||||
String uri = task.getURI().toString();
|
||||
if (uri.startsWith("file:") || task.getMethod() == FILE) {
|
||||
uri = DataHelper.stripHTML(task.getURI().getPath());
|
||||
buf.append(_("Install failed from {0}", uri));
|
||||
} else {
|
||||
buf.append(_("Transfer failed from {0}"));
|
||||
}
|
||||
if (reason != null && reason.length() > 0) {
|
||||
buf.append("<br>");
|
||||
buf.append(reason);
|
||||
}
|
||||
if (t != null && t.getMessage() != null && t.getMessage().length() > 0) {
|
||||
buf.append("<br>");
|
||||
buf.append(DataHelper.stripHTML(t.getMessage()));
|
||||
}
|
||||
buf.append("</b>");
|
||||
finishStatus(buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,8 @@ class PluginUpdateHandler implements Checker, Updater {
|
||||
public UpdateTask update(UpdateType type, UpdateMethod method, List<URI> updateSources,
|
||||
String appName, String newVersion, long maxTime) {
|
||||
if (type != UpdateType.PLUGIN ||
|
||||
method != UpdateMethod.HTTP || updateSources.isEmpty())
|
||||
(method != UpdateMethod.HTTP && method != UpdateMethod.FILE) ||
|
||||
updateSources.isEmpty())
|
||||
return null;
|
||||
Properties props = PluginStarter.pluginProperties(_context, appName);
|
||||
String oldVersion = props.getProperty("version");
|
||||
|
@ -82,16 +82,16 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
protected void update() {
|
||||
|
||||
_updated = false;
|
||||
if(_xpi2pURL.startsWith("file://")) {
|
||||
updateStatus("<b>" + _("Attempting to install from file {0}", _xpi2pURL) + "</b>");
|
||||
// strip off "file://"
|
||||
String xpi2pfile = _xpi2pURL.substring(7);
|
||||
if(xpi2pfile.length() == 0) {
|
||||
statusDone("<b>" + _("No file specified {0}", _xpi2pURL) + "</b>");
|
||||
if (_xpi2pURL.startsWith("file:") || _method == UpdateMethod.FILE) {
|
||||
// strip off file:// or just file:
|
||||
String xpi2pfile = _uri.getPath();
|
||||
if(xpi2pfile == null || xpi2pfile.length() == 0) {
|
||||
statusDone("<b>" + _("Bad URL {0}", _xpi2pURL) + "</b>");
|
||||
} else {
|
||||
// copy the contents of from to _updateFile
|
||||
long alreadyTransferred = (new File(xpi2pfile)).getAbsoluteFile().length();
|
||||
if(FileUtil.copy((new File(xpi2pfile)).getAbsolutePath(), _updateFile, true, false)) {
|
||||
updateStatus("<b>" + _("Attempting to install from file {0}", _xpi2pURL) + "</b>");
|
||||
transferComplete(alreadyTransferred, alreadyTransferred, 0L, _xpi2pURL, _updateFile, false);
|
||||
} else {
|
||||
statusDone("<b>" + _("Failed to install from file {0}, copy failed.", _xpi2pURL) + "</b>");
|
||||
|
Reference in New Issue
Block a user