No exception for missing file on cancelled installation

This commit is contained in:
René Pfeuffer
2020-11-24 18:18:50 +01:00
parent b67a0cb89d
commit fc9176ec5a
2 changed files with 15 additions and 6 deletions

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);
}
}
}