mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 19:15:52 +01:00
Cleanup code
This commit is contained in:
@@ -36,17 +36,7 @@ class PluginInstaller {
|
|||||||
Files.copy(input, file);
|
Files.copy(input, file);
|
||||||
|
|
||||||
verifyChecksum(plugin, input.hash(), file);
|
verifyChecksum(plugin, input.hash(), file);
|
||||||
InstalledPluginDescriptor pluginDescriptor = smpDDescriptorExtractor.extractPluginDescriptor(file);
|
verifyConditions(plugin, 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()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return new PendingPluginInstallation(plugin.install(), file);
|
return new PendingPluginInstallation(plugin.install(), file);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
cleanup(file);
|
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 {
|
private InputStream download(AvailablePlugin plugin) throws IOException {
|
||||||
return client.get(plugin.getDescriptor().getUrl()).request().contentAsStream();
|
return client.get(plugin.getDescriptor().getUrl()).request().contentAsStream();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user