From 1e67a5d2c89009daabdcded86e9844824ec7d1ed Mon Sep 17 00:00:00 2001 From: Syed Date: Fri, 27 Nov 2015 13:48:18 -0500 Subject: [PATCH] Fix secondary storage not working with swift --- .../resource/NfsSecondaryStorageResource.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 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 be5969104fd..888bb753084 100644 --- 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 @@ -356,9 +356,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) {