use platform independent file move (#376)
Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
committed by
Kai Zimmermann
parent
d15084974a
commit
8e7943dc4f
@@ -28,6 +28,7 @@ import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
|
|||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.io.BaseEncoding;
|
import com.google.common.io.BaseEncoding;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
import com.google.common.io.Files;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the {@link ArtifactRepository} to store artifacts on the
|
* 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);
|
final ArtifactFilesystem fileSystemArtifact = new ArtifactFilesystem(fileSHA1Naming);
|
||||||
if (fileSHA1Naming.exists()) {
|
if (fileSHA1Naming.exists()) {
|
||||||
FileUtils.deleteQuietly(file);
|
FileUtils.deleteQuietly(file);
|
||||||
} else if (!file.renameTo(fileSHA1Naming)) {
|
} else {
|
||||||
throw new ArtifactStoreException("Could not store the file " + fileSHA1Naming);
|
try {
|
||||||
|
Files.move(file, fileSHA1Naming);
|
||||||
|
} catch (final IOException e) {
|
||||||
|
throw new ArtifactStoreException("Could not store the file " + fileSHA1Naming, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file.delete();
|
file.delete();
|
||||||
|
|||||||
Reference in New Issue
Block a user