CLOUDSTACK-5900: Failed to delete template/ISO that failed to download.
(cherry picked from commit 8024f2cc70c31ab22efe574e866cc9de7a48da28)

Signed-off-by: Animesh Chaturvedi <anim...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a5f73b72
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a5f73b72
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a5f73b72

Branch: refs/heads/4.3
Commit: a5f73b7285f8bec5dd0374060d5543a32297ed04
Parents: 16dbb20
Author: Sanjay Tripathi <sanjay.tripa...@citrix.com>
Authored: Thu Jan 30 13:12:59 2014 +0530
Committer: Animesh Chaturvedi <anim...@apache.org>
Committed: Thu Jan 30 18:12:15 2014 -0800

----------------------------------------------------------------------
 .../storage/resource/NfsSecondaryStorageResource.java       | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5f73b72/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git 
a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
 
b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index 0ce36ed..39d5b48 100755
--- 
a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ 
b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -1740,11 +1740,12 @@ public class NfsSecondaryStorageResource extends 
ServerResourceBase implements S
                 parent += File.separator;
             }
             String absoluteTemplatePath = parent + relativeTemplatePath;
-            File tmpltParent;
-            if(absoluteTemplatePath.endsWith(String.valueOf(obj.getId()))) {
-                tmpltParent = new File(absoluteTemplatePath);
+            File tmpltPath = new File(absoluteTemplatePath);
+            File tmpltParent = null;
+            if(tmpltPath.exists() && tmpltPath.isDirectory()) {
+                tmpltParent = tmpltPath;
             } else {
-                tmpltParent = new File(absoluteTemplatePath).getParentFile();
+                tmpltParent = tmpltPath.getParentFile();
             }
             String details = null;
             if (!tmpltParent.exists()) {

Reply via email to