From 29c12bb78c37bf8c7ae4c2fd6f528974fc44e707 Mon Sep 17 00:00:00 2001 From: Pierre-Luc Dion Date: Thu, 14 Aug 2014 10:15:27 -0400 Subject: [PATCH 1/2] CLOUDSTACK-7343; fix create folder in copyFromSwiftToNfs --- .../resource/NfsSecondaryStorageResource.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java index 78f4bf19a91..f095403322a 100755 --- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java +++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java @@ -320,9 +320,17 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S try { String downloadPath = determineStorageTemplatePath(storagePath, destPath); final File downloadDirectory = _storage.getFile(downloadPath); - if (!downloadDirectory.mkdirs()) { - return new CopyCmdAnswer("Failed to create download directory " + downloadPath); - } + + if (downloadDirectory.exists()) { + s_logger.debug("Directory " + downloadPath + " already exists"); + } else { + if (!downloadDirectory.mkdirs()) { + final String errMsg = "Unable to create directory " + downloadPath + " to copy from Swift to cache."; + s_logger.error(errMsg); + return new CopyCmdAnswer(errMsg); + } + } + File destFile = SwiftUtil.getObject(swiftTO, downloadDirectory, srcData.getPath()); return postProcessing(destFile, downloadPath, destPath, srcData, destData); } catch (Exception e) { From 62d9843e0ce9e9c2418258697e583dd9de4a68d0 Mon Sep 17 00:00:00 2001 From: Pierre-Luc Dion Date: Thu, 14 Aug 2014 13:07:32 -0400 Subject: [PATCH 2/2] NfsSecondaryStorageResource.java:remove empty spaces --- .../storage/resource/NfsSecondaryStorageResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java index f095403322a..f9a06f11b7c 100755 --- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java +++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java @@ -329,7 +329,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S s_logger.error(errMsg); return new CopyCmdAnswer(errMsg); } - } + } File destFile = SwiftUtil.getObject(swiftTO, downloadDirectory, srcData.getPath()); return postProcessing(destFile, downloadPath, destPath, srcData, destData);