X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fa2%2FAbstractProvisioningSource.java;h=f946add692a062940f0d64f3e2ef44f10e529be5;hb=c692c089327ab02a19dc5dae90bb003cdf75956d;hp=800635c9e93748214b95c9b286bce88b6be41352;hpb=f401547cb29a0900f8773c9b17c6cbd32b28cefd;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/a2/AbstractProvisioningSource.java b/org.argeo.init/src/org/argeo/init/a2/AbstractProvisioningSource.java index 800635c9e..f946add69 100644 --- a/org.argeo.init/src/org/argeo/init/a2/AbstractProvisioningSource.java +++ b/org.argeo.init/src/org/argeo/init/a2/AbstractProvisioningSource.java @@ -49,16 +49,19 @@ public abstract class AbstractProvisioningSource implements ProvisioningSource { } else { Path locatorPath = (Path) locator; Path pathToUse; - if (locator instanceof Path && Files.isDirectory(locatorPath)) + boolean isTemp = false; + if (locator instanceof Path && Files.isDirectory(locatorPath)) { pathToUse = toTempJar(locatorPath); - else + isTemp = true; + } else { pathToUse = locatorPath; + } Bundle bundle; try (InputStream in = newInputStream(pathToUse)) { bundle = bc.installBundle(locatorPath.toAbsolutePath().toString(), in); } - if (pathToUse != null) + if (isTemp && pathToUse != null) Files.deleteIfExists(pathToUse); return bundle; } @@ -76,14 +79,20 @@ public abstract class AbstractProvisioningSource implements ProvisioningSource { bundle.update(in); } } else { - Path tempJar = null; - if (locator instanceof Path && Files.isDirectory((Path) locator)) - tempJar = toTempJar((Path) locator); - try (InputStream in = newInputStream(tempJar != null ? tempJar : locator)) { + Path locatorPath = (Path) locator; + Path pathToUse; + boolean isTemp = false; + if (locator instanceof Path && Files.isDirectory(locatorPath)) { + pathToUse = toTempJar(locatorPath); + isTemp = true; + } else { + pathToUse = locatorPath; + } + try (InputStream in = newInputStream(pathToUse)) { bundle.update(in); } - if (tempJar != null) - Files.deleteIfExists(tempJar); + if (isTemp && pathToUse != null) + Files.deleteIfExists(pathToUse); } } catch (BundleException | IOException e) { throw new A2Exception("Cannot update module " + module, e);