CP-13038: Takes care of the case when the user downloads multiple files(by going back in the wizard and selecting a different update). When clicking cancel or when the install is finished, all the downloaded files are removed.

This commit is contained in:
Carmen Agimof 2015-07-15 16:36:37 +01:00
parent 149e6f8c1e
commit 3f7fd89f87
2 changed files with 12 additions and 8 deletions

View File

@ -250,10 +250,7 @@ namespace XenAdmin.Wizards.PatchingWizard
RunMultipleActions(Messages.REVERT_WIZARD_CHANGES, Messages.REVERTING_WIZARD_CHANGES,
Messages.REVERTED_WIZARD_CHANGES, subActions);
if (PatchingWizard_SelectPatchPage.SelectedUpdateAlert != null && PatchingWizard_UploadPage.SelectedNewPatch != null)
{
File.Delete(PatchingWizard_UploadPage.SelectedNewPatch);
}
RemoveDownloadedPatches();
base.OnCancel();
}
@ -270,6 +267,14 @@ namespace XenAdmin.Wizards.PatchingWizard
RunMultipleActions(Messages.REMOVE_UPDATES, Messages.REMOVING_UPDATES, Messages.REMOVED_UPDATES, subActions);
}
private void RemoveDownloadedPatches()
{
foreach (string downloadedPatch in PatchingWizard_UploadPage.AllDownloadedPatches)
{
File.Delete(downloadedPatch);
}
}
protected override void FinishWizard()
{
if (PatchingWizard_UploadPage.NewUploadedPatches != null)
@ -284,10 +289,7 @@ namespace XenAdmin.Wizards.PatchingWizard
if (PatchingWizard_UploadPage.AllCreatedSuppPackVdis != null)
RemoveTemporaryVdis();
if (PatchingWizard_SelectPatchPage.SelectedUpdateAlert != null)
{
File.Delete(PatchingWizard_UploadPage.SelectedNewPatch);
}
RemoveDownloadedPatches();
base.FinishWizard();
}

View File

@ -45,6 +45,7 @@ namespace XenAdmin.Wizards.PatchingWizard
get { return _patch; }
}
public List<string> AllDownloadedPatches = new List<string>();
public readonly List<VDI> AllCreatedSuppPackVdis = new List<VDI>();
public Dictionary<Host, VDI> SuppPackVdis = new Dictionary<Host, VDI>();
@ -367,6 +368,7 @@ namespace XenAdmin.Wizards.PatchingWizard
if (action is DownloadAndUnzipXenServerPatchAction)
{
SelectedNewPatch = ((DownloadAndUnzipXenServerPatchAction)action).PatchPath;
AllDownloadedPatches.Add(SelectedNewPatch);
PrepareUploadActions();
TryUploading();
}