You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2019/06/05 16:46:38 UTC
[karaf-cave] branch master updated: Delete the temporary file if
there is an error creating the resource
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf-cave.git
The following commit(s) were added to refs/heads/master by this push:
new a76d36e Delete the temporary file if there is an error creating the resource
new b3256bd Merge pull request #23 from coheigea/del_temp_file
a76d36e is described below
commit a76d36eaa0d63d23a42f0188d69beffdd5e7edf4
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Wed Jun 5 16:35:57 2019 +0100
Delete the temporary file if there is an error creating the resource
---
.../apache/karaf/cave/server/storage/CaveRepositoryImpl.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java b/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
index 6dfcc98..7a3176d 100644
--- a/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
+++ b/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
@@ -184,7 +184,14 @@ public class CaveRepositoryImpl implements CaveRepository {
Files.copy(is, temp);
}
// update the repository.xml
- ResourceImpl resource = createResource(temp.toUri().toURL());
+ ResourceImpl resource = null;
+ try {
+ resource = createResource(temp.toUri().toURL());
+ } catch (BundleException ex) {
+ Files.delete(temp);
+ throw ex;
+ }
+
Path destination = getLocationPath().resolve(ResolverUtil.getSymbolicName(resource) + "-" + ResolverUtil.getVersion(resource) + ".jar");
if (Files.exists(destination)) {
Files.delete(temp);
@@ -194,6 +201,7 @@ public class CaveRepositoryImpl implements CaveRepository {
Files.move(temp, destination);
resource = createResource(destination.toUri().toURL());
addResources(Collections.<Resource>singletonList(resource));
+
}
/**