mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 02:55:56 +01:00
Cleanup code
This commit is contained in:
@@ -36,17 +36,7 @@ class PluginInstaller {
|
||||
Files.copy(input, file);
|
||||
|
||||
verifyChecksum(plugin, input.hash(), file);
|
||||
InstalledPluginDescriptor pluginDescriptor = smpDDescriptorExtractor.extractPluginDescriptor(file);
|
||||
if (!pluginDescriptor.getCondition().isSupported()) {
|
||||
cleanup(file);
|
||||
throw new PluginConditionFailedException(
|
||||
pluginDescriptor.getCondition(),
|
||||
String.format(
|
||||
"could not load plugin %s, the plugin condition does not match",
|
||||
plugin.getDescriptor().getInformation().getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
verifyConditions(plugin, file);
|
||||
return new PendingPluginInstallation(plugin.install(), file);
|
||||
} catch (IOException ex) {
|
||||
cleanup(file);
|
||||
@@ -77,6 +67,20 @@ class PluginInstaller {
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyConditions(AvailablePlugin plugin, Path file) throws IOException {
|
||||
InstalledPluginDescriptor pluginDescriptor = smpDDescriptorExtractor.extractPluginDescriptor(file);
|
||||
if (!pluginDescriptor.getCondition().isSupported()) {
|
||||
cleanup(file);
|
||||
throw new PluginConditionFailedException(
|
||||
pluginDescriptor.getCondition(),
|
||||
String.format(
|
||||
"could not load plugin %s, the plugin condition does not match",
|
||||
plugin.getDescriptor().getInformation().getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream download(AvailablePlugin plugin) throws IOException {
|
||||
return client.get(plugin.getDescriptor().getUrl()).request().contentAsStream();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user