* Plugins:

- Only stop a plugin before update if it was running
    - Don't start a plugin after update if it was disabled
    - Disable plugin if it fails version checks at startup
This commit is contained in:
zzz
2012-01-15 16:59:33 +00:00
parent b5d77685b9
commit 3d2d60469e
2 changed files with 46 additions and 10 deletions

View File

@@ -286,6 +286,7 @@ public class PluginUpdateHandler extends UpdateHandler {
return;
}
boolean wasRunning = false;
File destDir = new SecureDirectory(appDir, appName);
if (destDir.exists()) {
if (Boolean.valueOf(props.getProperty("install-only")).booleanValue()) {
@@ -350,14 +351,16 @@ public class PluginUpdateHandler extends UpdateHandler {
return;
}
// check if it is running first?
try {
if (!PluginStarter.stopPlugin(_context, appName)) {
// failed, ignore
if (PluginStarter.isPluginRunning(appName, _context)) {
wasRunning = true;
try {
if (!PluginStarter.stopPlugin(_context, appName)) {
// failed, ignore
}
} catch (Throwable e) {
// no updateStatus() for this one
_log.error("Error stopping plugin " + appName, e);
}
} catch (Throwable e) {
// no updateStatus() for this one
_log.error("Error stopping plugin " + appName, e);
}
} else {
@@ -390,8 +393,8 @@ public class PluginUpdateHandler extends UpdateHandler {
pluginProps.setProperty(PluginStarter.PREFIX + appName + PluginStarter.ENABLED, "false");
PluginStarter.storePluginProperties(pluginProps);
}
} else {
// start everything
} else if (wasRunning || PluginStarter.isPluginEnabled(appName)) {
// start everything unless it was disabled and not running before
try {
if (PluginStarter.startPlugin(_context, appName)) {
String linkName = ConfigClientsHelper.stripHTML(props, "consoleLinkName_" + Messages.getLanguage(_context));
@@ -411,6 +414,8 @@ public class PluginUpdateHandler extends UpdateHandler {
statusDone("<b>" + _("Plugin {0} installed but failed to start", appName) + ": " + e + "</b>");
_log.error("Error starting plugin " + appName, e);
}
} else {
statusDone("<b>" + _("Plugin {0} installed", appName) + "</b>");
}
}