From 8ac6774e80bcd188e62d58c3aa0a69c5433f33e9 Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Wed, 19 Oct 2016 11:29:57 +0100 Subject: [PATCH] CA-225731: XenCenter: Find the ISO update in the zip file defined in CFU Signed-off-by: Gabor Apati-Nagy --- .../PatchingWizard_SelectPatchPage.cs | 2 +- .../PatchingWizard_UploadPage.cs | 2 +- .../PlanActions/DownloadPatchPlanAction.cs | 2 +- .../DownloadAndUnzipXenServerPatchAction.cs | 28 +++++++++---------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectPatchPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectPatchPage.cs index 13dba3f89..047afa3a1 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectPatchPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectPatchPage.cs @@ -341,7 +341,7 @@ namespace XenAdmin.Wizards.PatchingWizard private string UpdateExtension { - get { return "." + Branding.Update; } + get { return SelectedUpdateType != UpdateType.ISO ? "." + Branding.Update : ".iso"; } } private bool isValidFile(string fileName) diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_UploadPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_UploadPage.cs index 293289be1..d5886d636 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_UploadPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_UploadPage.cs @@ -105,7 +105,7 @@ namespace XenAdmin.Wizards.PatchingWizard Uri address = new Uri(patchUri); string tempFile = Path.GetTempFileName(); - bool isIso = patchUri.ToLowerInvariant().EndsWith("iso"); + bool isIso = SelectedUpdateType == UpdateType.ISO; downloadAction = new DownloadAndUnzipXenServerPatchAction(SelectedUpdateAlert.Name, address, tempFile, isIso ? "iso" : Branding.Update); diff --git a/XenAdmin/Wizards/PatchingWizard/PlanActions/DownloadPatchPlanAction.cs b/XenAdmin/Wizards/PatchingWizard/PlanActions/DownloadPatchPlanAction.cs index e09e75bf8..312d0f688 100644 --- a/XenAdmin/Wizards/PatchingWizard/PlanActions/DownloadPatchPlanAction.cs +++ b/XenAdmin/Wizards/PatchingWizard/PlanActions/DownloadPatchPlanAction.cs @@ -91,7 +91,7 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions bool isIso = patchUri.ToLowerInvariant().EndsWith("iso"); - var downloadAction = new DownloadAndUnzipXenServerPatchAction(patch.Name, address, tempFileName, isIso ? "iso" : Branding.Update); + var downloadAction = new DownloadAndUnzipXenServerPatchAction(patch.Name, address, tempFileName); if (downloadAction != null) { diff --git a/XenModel/Actions/Updates/DownloadAndUnzipXenServerPatchAction.cs b/XenModel/Actions/Updates/DownloadAndUnzipXenServerPatchAction.cs index 6e9abdc46..d0b8c1aa1 100644 --- a/XenModel/Actions/Updates/DownloadAndUnzipXenServerPatchAction.cs +++ b/XenModel/Actions/Updates/DownloadAndUnzipXenServerPatchAction.cs @@ -59,7 +59,7 @@ namespace XenAdmin.Actions } public DownloadAndUnzipXenServerPatchAction(string patchName, Uri uri, string outputFileName) - : this(patchName, uri, outputFileName, InvisibleMessages.XEN_UPDATE) + : this(patchName, uri, outputFileName, null) { } public DownloadAndUnzipXenServerPatchAction(string patchName, Uri uri, string outputFileName, string updateFileExtension) @@ -123,14 +123,22 @@ namespace XenAdmin.Actions while (iterator.HasNext()) { - if (Path.GetExtension(iterator.CurrentFileName()) == "." + updateFileExtension) + string currentExtension = Path.GetExtension(iterator.CurrentFileName()); + + if (!string.IsNullOrEmpty(updateFileExtension) && currentExtension == "." + updateFileExtension + || currentExtension == ".iso" || currentExtension == ".xsupdate") { string path = Path.Combine(Path.GetDirectoryName(outFileName), iterator.CurrentFileName()); + log.DebugFormat("Found '{0}' in the downloaded archive when looking for a '{1}' file. Extracting...", iterator.CurrentFileName(), currentExtension); + using (Stream outputStream = new FileStream(path, FileMode.Create)) { iterator.ExtractCurrentFile(outputStream); PatchPath = path; + + log.DebugFormat("Update file extracted to '{0}'", path); + break; } } @@ -177,18 +185,10 @@ namespace XenAdmin.Actions if (Cancelling) throw new CancelledException(); - if (updateFileExtension.ToLowerInvariant() != "iso") - { - log.DebugFormat("Extracting XenServer patch '{0}'", updateName); - Description = string.Format(Messages.DOWNLOAD_AND_EXTRACT_ACTION_EXTRACTING_DESC, updateName); - ExtractFile(); - log.DebugFormat("Extracting XenServer patch '{0}' completed", updateName); - } - else - { - log.DebugFormat("ISO file downloaded ('{0}'), skipping unzip. Setting PatchPath to '{1}'", updateName, outFileName); - PatchPath = outFileName; - } + log.DebugFormat("Extracting XenServer patch '{0}'", updateName); + Description = string.Format(Messages.DOWNLOAD_AND_EXTRACT_ACTION_EXTRACTING_DESC, updateName); + ExtractFile(); + log.DebugFormat("Extracting XenServer patch '{0}' completed", updateName); Description = Messages.COMPLETED; MarkCompleted();