mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	More protective cleanup when exporting snaphost to reduce chances of leaving intermediate files behind under soft error conditions
This commit is contained in:
		
							parent
							
								
									83bc7d1c81
								
							
						
					
					
						commit
						f0e048a968
					
				| @ -1187,15 +1187,16 @@ public class VirtualMachineMO extends BaseMO { | ||||
| 		try { | ||||
| 			if(state == HttpNfcLeaseState.ready) { | ||||
| 				final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter(); | ||||
| 
 | ||||
|                 boolean success = false; | ||||
|                 List<String> fileNames = new ArrayList<String>(); | ||||
| 				try { | ||||
| 					HttpNfcLeaseInfo leaseInfo = leaseMo.getLeaseInfo(); | ||||
| 					final long totalBytes = leaseInfo.getTotalDiskCapacityInKB() * 1024; | ||||
| 					long totalBytesDownloaded = 0; | ||||
| 					 | ||||
| 					HttpNfcLeaseDeviceUrl[] deviceUrls = leaseInfo.getDeviceUrl(); | ||||
| 					if(deviceUrls != null) { | ||||
| 						List<String> fileNames = new ArrayList<String>(); | ||||
| 						 | ||||
| 					if(deviceUrls != null) { | ||||
| 						OvfFile[] ovfFiles = new OvfFile[deviceUrls.length];   | ||||
| 						for (int i = 0; i < deviceUrls.length; i++) {   | ||||
| 							String deviceId = deviceUrls[i].getKey();   | ||||
| @ -1251,19 +1252,25 @@ public class VirtualMachineMO extends BaseMO { | ||||
|                             } | ||||
| 					         | ||||
| 					        String result = command.execute(); | ||||
| 					        if(result == null) { | ||||
| 					        	if(leaveOvaFileOnly) { | ||||
| 							        for(String name: fileNames) { | ||||
|                                         new File(name).delete(); | ||||
|                                     } | ||||
| 					        	} | ||||
| 					        if(result == null) { | ||||
| 					            success = true; | ||||
| 					        } | ||||
| 						} | ||||
| 						} | ||||
| 					} | ||||
| 				} catch(Throwable e) { | ||||
| 					s_logger.error("Unexpected exception ", e); | ||||
| 				} finally { | ||||
| 					progressReporter.close(); | ||||
| 					progressReporter.close(); | ||||
| 
 | ||||
| 					if(leaveOvaFileOnly) { | ||||
|                         for(String name : fileNames) { | ||||
|                             new File(name).delete(); | ||||
|                         } | ||||
| 					} | ||||
| 					 | ||||
| 					if(!success) { | ||||
| 					    new File(exportDir + File.separator + exportName + ".ova").delete(); | ||||
| 					}  | ||||
| 				} | ||||
| 			} | ||||
| 		} finally { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user