Merge pull request #1442 from scm-manager/feature/improve_plugin_update_logging

Improve logging for plugin update installation
This commit is contained in:
René Pfeuffer
2020-11-24 18:52:15 +01:00
committed by GitHub
4 changed files with 30 additions and 10 deletions

View File

@@ -192,10 +192,16 @@ public class DefaultPluginManager implements PluginManager {
dependencyTracker.addInstalled(plugin.getDescriptor());
pendingInstallations.add(pending);
eventBus.post(new PluginEvent(PluginEvent.PluginEventType.INSTALLED, plugin));
} catch (PluginInstallException ex) {
cancelPending(pendingInstallations);
eventBus.post(new PluginEvent(PluginEvent.PluginEventType.INSTALLATION_FAILED, plugin));
throw ex;
} catch (PluginInstallException installException) {
try {
cancelPending(pendingInstallations);
} catch (PluginFailedToCancelInstallationException cancelInstallationException) {
LOG.error("could not install plugin {}; uninstallation failed (see next exception)", plugin.getDescriptor().getInformation().getName(), installException);
throw cancelInstallationException;
} finally {
eventBus.post(new PluginEvent(PluginEvent.PluginEventType.INSTALLATION_FAILED, plugin));
}
throw installException;
}
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.plugin;
import org.slf4j.Logger;
@@ -50,10 +50,14 @@ class PendingPluginInstallation {
void cancel() {
String name = plugin.getDescriptor().getInformation().getName();
LOG.info("cancel installation of plugin {}", name);
try {
Files.delete(file);
} catch (IOException ex) {
throw new PluginFailedToCancelInstallationException("failed to cancel plugin installation ", name, ex);
if (Files.exists(file)) {
try {
Files.delete(file);
} catch (IOException ex) {
throw new PluginFailedToCancelInstallationException("failed to cancel plugin installation ", name, ex);
}
} else {
LOG.info("plugin file {} did not exists for plugin {}; nothing deleted", file, name);
}
}
}