From 8e7943dc4fa4f5e9770a96365d77f128e39a35f0 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Tue, 6 Dec 2016 19:34:59 +0100 Subject: [PATCH] use platform independent file move (#376) Signed-off-by: Michael Hirsch --- .../repository/ArtifactFilesystemRepository.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hawkbit-artifact-repository-filesystem/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepository.java b/hawkbit-artifact-repository-filesystem/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepository.java index ba14e432f..981a32567 100644 --- a/hawkbit-artifact-repository-filesystem/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepository.java +++ b/hawkbit-artifact-repository-filesystem/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepository.java @@ -28,6 +28,7 @@ import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; import com.google.common.base.Splitter; import com.google.common.io.BaseEncoding; import com.google.common.io.ByteStreams; +import com.google.common.io.Files; /** * Implementation of the {@link ArtifactRepository} to store artifacts on the @@ -129,8 +130,12 @@ public class ArtifactFilesystemRepository implements ArtifactRepository { final ArtifactFilesystem fileSystemArtifact = new ArtifactFilesystem(fileSHA1Naming); if (fileSHA1Naming.exists()) { FileUtils.deleteQuietly(file); - } else if (!file.renameTo(fileSHA1Naming)) { - throw new ArtifactStoreException("Could not store the file " + fileSHA1Naming); + } else { + try { + Files.move(file, fileSHA1Naming); + } catch (final IOException e) { + throw new ArtifactStoreException("Could not store the file " + fileSHA1Naming, e); + } } file.delete();