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 <me@dualfroz.com>
Link: https://lore.proxmox.com/20260929135840.2748665-3-me@dualfroz.com
This commit is contained in:
dualfroz committed 2026-09-30 11:39:38 +02:00
1 parent 42ab0e5059
commit 11c2368e04
1 file changed
+29 -3
+29 -3
View File
@@ -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: [
{