CLOUDSTACK-7343; fix create folder in copyFromSwiftToNfs

This commit is contained in:
Pierre-Luc Dion 2014-08-14 10:15:27 -04:00
parent c4d1bf7f24
commit 29c12bb78c
1 changed files with 11 additions and 3 deletions

View File

@ -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) {