Small Artifact storage refactoring (#2648)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -16,7 +16,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* Configuration properties for the file-system repository, e.g. the base-path to store the files.
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties("org.eclipse.hawkbit.repository.file")
|
||||
@ConfigurationProperties("org.eclipse.hawkbit.artifact.fs")
|
||||
public class FileArtifactProperties {
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.eclipse.hawkbit.artifact.ArtifactStorage;
|
||||
import org.eclipse.hawkbit.artifact.exception.ArtifactBinaryNotFoundException;
|
||||
import org.eclipse.hawkbit.artifact.exception.ArtifactStoreException;
|
||||
import org.eclipse.hawkbit.artifact.model.ArtifactHashes;
|
||||
import org.eclipse.hawkbit.artifact.model.StoredArtifactInfo;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
@@ -75,17 +74,14 @@ public class FileArtifactStorage extends AbstractArtifactStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StoredArtifactInfo store(final String tenant, final ArtifactHashes base16Hashes, final String contentType, final String tempFile)
|
||||
protected void store(final String tenant, final ArtifactHashes base16Hashes, final String contentType, final File tempFile)
|
||||
throws IOException {
|
||||
final File file = new File(tempFile);
|
||||
final File fileSHA1Naming = getFile(tenant, base16Hashes.sha1());
|
||||
if (fileSHA1Naming.exists()) {
|
||||
FileUtils.deleteQuietly(file);
|
||||
FileUtils.deleteQuietly(tempFile);
|
||||
} else {
|
||||
Files.move(file.toPath(), fileSHA1Naming.toPath());
|
||||
Files.move(tempFile.toPath(), fileSHA1Naming.toPath());
|
||||
}
|
||||
|
||||
return new StoredArtifactInfo(contentType, fileSHA1Naming.length(), base16Hashes);
|
||||
}
|
||||
|
||||
private File getFile(final String tenant, final String sha1) {
|
||||
|
||||
Reference in New Issue
Block a user