From 11c2368e04ce468ee1d026767b6c7a2dcb15ef8e Mon Sep 17 00:00:00 2001 From: Michal Fox Date: Tue, 29 Sep 2026 15:58:40 +0200 Subject: [PATCH] fix #8015: ui: download url: let the user choose the .img image format Like for the upload, '.raw' was appended to the name of '.img' images downloaded as import content, which breaks importing images in other formats, such as the qcow2 based Ubuntu cloud images. After querying the URL of such an image, show a format selector and append the extension of the selected format to the file name instead. Signed-off-by: Michal Fox Link: https://lore.proxmox.com/20260929135840.2748665-3-me@dualfroz.com --- www/manager6/window/DownloadUrlToStorage.js | 32 +++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/www/manager6/window/DownloadUrlToStorage.js b/www/manager6/window/DownloadUrlToStorage.js index f1c4392..be31fb5 100644 --- a/www/manager6/window/DownloadUrlToStorage.js +++ b/www/manager6/window/DownloadUrlToStorage.js @@ -30,6 +30,7 @@ Ext.define('PVE.window.DownloadUrlToStorage', { size: '-', mimetype: '-', enableQuery: true, + needsFormat: false, }, }, @@ -82,6 +83,7 @@ Ext.define('PVE.window.DownloadUrlToStorage', { let filename = data.filename || ''; let compression = '__default__'; + let needsFormat = false; if (view.content === 'iso') { const matches = filename.match(/^(.+)\.(gz|lzo|zst|bz2)$/i); if (matches) { @@ -89,10 +91,12 @@ Ext.define('PVE.window.DownloadUrlToStorage', { compression = matches[2].toLowerCase(); } } else if (view.content === 'import') { - if (filename.endsWith('.img')) { - filename += '.raw'; - } + // the extension does not tell the image format, the user has to select it + needsFormat = filename.endsWith('.img'); } + me.queriedName = filename; + me.getViewModel().set('needsFormat', needsFormat); + me.lookup('imageFormat').setValue(null); view.setValues({ filename, @@ -106,6 +110,12 @@ Ext.define('PVE.window.DownloadUrlToStorage', { }); }, + formatChange: function (field, format) { + if (format) { + this.getView().setValues({ filename: `${this.queriedName}.${format}` }); + } + }, + hashChange: function (field) { let checksum = Ext.getCmp('downloadUrlChecksum'); if (field.getValue() === '__default__') { @@ -169,6 +179,22 @@ Ext.define('PVE.window.DownloadUrlToStorage', { return this.processRawValue(this.getRawValue())?.trim(); }, }, + { + xtype: 'pveDiskFormatSelector', + reference: 'imageFormat', + fieldLabel: gettext('Format'), + submitValue: false, + allowBlank: false, + hidden: true, + disabled: true, + bind: { + hidden: '{!needsFormat}', + disabled: '{!needsFormat}', + }, + listeners: { + change: 'formatChange', + }, + }, ], column1: [ {