mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	CLOUDSTACK-5900: Failed to delete template/ISO that failed to download.
This commit is contained in:
		
							parent
							
								
									1c57dd7bcd
								
							
						
					
					
						commit
						1c4bbecc4a
					
				| @ -1716,16 +1716,23 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S | |||||||
|                 parent += File.separator; |                 parent += File.separator; | ||||||
|             } |             } | ||||||
|             String absoluteTemplatePath = parent + relativeTemplatePath; |             String absoluteTemplatePath = parent + relativeTemplatePath; | ||||||
|             File tmpltDir = new File(absoluteTemplatePath); | 
 | ||||||
|  |             File tmpltParent; | ||||||
|  |             if(absoluteTemplatePath.endsWith(String.valueOf(obj.getId()))) { | ||||||
|  |                 tmpltParent = new File(absoluteTemplatePath); | ||||||
|  |             } else { | ||||||
|  |                 tmpltParent = new File(absoluteTemplatePath).getParentFile(); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|             String details = null; |             String details = null; | ||||||
|             if (!tmpltDir.exists()) { |             if (!tmpltParent.exists()) { | ||||||
|                 details = "template parent directory " + tmpltDir.getName() + " doesn't exist"; |                 details = "template parent directory " + tmpltParent.getName() + " doesn't exist"; | ||||||
|                 s_logger.debug(details); |                 s_logger.debug(details); | ||||||
|                 return new Answer(cmd, true, details); |                 return new Answer(cmd, true, details); | ||||||
|             } |             } | ||||||
|             File[] tmpltFiles = tmpltDir.listFiles(); |             File[] tmpltFiles = tmpltParent.listFiles(); | ||||||
|             if (tmpltFiles == null || tmpltFiles.length == 0) { |             if (tmpltFiles == null || tmpltFiles.length == 0) { | ||||||
|                 details = "No files under template parent directory " + tmpltDir.getName(); |                 details = "No files under template parent directory " + tmpltParent.getName(); | ||||||
|                 s_logger.debug(details); |                 s_logger.debug(details); | ||||||
|             } else { |             } else { | ||||||
|                 boolean found = false; |                 boolean found = false; | ||||||
| @ -1751,12 +1758,12 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 if (!found) { |                 if (!found) { | ||||||
|                     details = "Can not find template.properties under " + tmpltDir.getName(); |                     details = "Can not find template.properties under " + tmpltParent.getName(); | ||||||
|                     s_logger.debug(details); |                     s_logger.debug(details); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             if (!tmpltDir.delete()) { |             if (!tmpltParent.delete()) { | ||||||
|                 details = "Unable to delete directory " + tmpltDir.getName() + " under Template path " + relativeTemplatePath; |                 details = "Unable to delete directory " + tmpltParent.getName() + " under Template path " + relativeTemplatePath; | ||||||
|                 s_logger.debug(details); |                 s_logger.debug(details); | ||||||
|                 return new Answer(cmd, false, details); |                 return new Answer(cmd, false, details); | ||||||
|             } |             } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user