Skip to content

Commit 736bf54

Browse files
lbtqDaanHoogland
authored andcommitted
Changed logic for copying snapshot from S3 to NFS staging store to prevent needless failure.
Signed-off-by: Daan Hoogland <[email protected]>
1 parent 60f4203 commit 736bf54

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,14 @@ protected Answer copyFromS3ToNfs(CopyCommand cmd, DataTO srcData, S3TO s3, DataT
340340
String downloadPath = determineStorageTemplatePath(storagePath, destPath);
341341
final File downloadDirectory = _storage.getFile(downloadPath);
342342

343-
if (!downloadDirectory.mkdirs()) {
344-
final String errMsg = "Unable to create directory " + downloadPath + " to copy from S3 to cache.";
345-
s_logger.error(errMsg);
346-
return new CopyCmdAnswer(errMsg);
347-
} else {
343+
if (downloadDirectory.exists()) {
348344
s_logger.debug("Directory " + downloadPath + " already exists");
345+
} else {
346+
if (!downloadDirectory.mkdirs()) {
347+
final String errMsg = "Unable to create directory " + downloadPath + " to copy from S3 to cache.";
348+
s_logger.error(errMsg);
349+
return new CopyCmdAnswer(errMsg);
350+
}
349351
}
350352

351353
File destFile = S3Utils.getFile(s3, s3.getBucketName(), srcData.getPath(), downloadDirectory, new FileNamingStrategy() {

0 commit comments

Comments
 (0)