From 98efd6311047e958f8776ebacb44e55ea5c5b378 Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Mon, 13 Oct 2025 14:48:37 +0800 Subject: [PATCH] fix: abort upload when switch to URL option (#552) Signed-off-by: Andy Lee --- .../pages/c/_cluster/airgapupgrade/index.vue | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/pkg/harvester/pages/c/_cluster/airgapupgrade/index.vue b/pkg/harvester/pages/c/_cluster/airgapupgrade/index.vue index 99fc7cf9..4cfb2c33 100644 --- a/pkg/harvester/pages/c/_cluster/airgapupgrade/index.vue +++ b/pkg/harvester/pages/c/_cluster/airgapupgrade/index.vue @@ -215,19 +215,18 @@ export default { if (this.imageSource === IMAGE_METHOD.NEW) { this.imageValue.metadata.annotations[HCI_ANNOTATIONS.OS_UPGRADE_IMAGE] = 'True'; - if (this.sourceType === UPLOAD && this.uploadImageId !== '') { + if (this.sourceType === UPLOAD && this.uploadImageId !== '') { // upload new image this.value.spec.image = this.uploadImageId; - } else if (this.sourceType === DOWNLOAD) { + } else if (this.sourceType === DOWNLOAD) { // give URL to download new image this.imageValue.spec.sourceType = DOWNLOAD; - if (!this.imageValue.spec.url) { this.errors.push(this.$store.getters['i18n/t']('harvester.setting.upgrade.imageUrl')); buttonCb(false); return; } - res = await this.imageValue.save(); + this.value.spec.image = res.id; } } else if (this.imageSource === IMAGE_METHOD.EXIST) { @@ -247,7 +246,6 @@ export default { if (this.skipSingleReplicaDetachedVolFeatureEnabled) { this.value.metadata.annotations = { [HCI_ANNOTATIONS.SKIP_SINGLE_REPLICA_DETACHED_VOL]: JSON.stringify(this.skipSingleReplicaDetachedVol) }; } - await this.value.save(); this.done(); buttonCb(true); @@ -334,6 +332,22 @@ export default { }, watch: { + async sourceType(neu) { + if (neu === DOWNLOAD && this.imageValue && this.uploadController) { + if (this.uploadController) { + this.uploadController.abort(); + } + + try { + await this.imageValue.remove(); + await this.initImageValue(); + } catch (error) { + // eslint-disable-next-line no-console + console.error('Error occurred while removing imageValue:', error); + } + } + }, + imageSource(neu) { if (neu !== IMAGE_METHOD.DELETE) { this.deleteImageId = '';