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:
1 parent
42ab0e5059
commit
11c2368e04
1 file changed
+29
-3
@@ -30,6 +30,7 @@ Ext.define('PVE.window.DownloadUrlToStorage', {
|
|||||||
size: '-',
|
size: '-',
|
||||||
mimetype: '-',
|
mimetype: '-',
|
||||||
enableQuery: true,
|
enableQuery: true,
|
||||||
|
needsFormat: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -82,6 +83,7 @@ Ext.define('PVE.window.DownloadUrlToStorage', {
|
|||||||
|
|
||||||
let filename = data.filename || '';
|
let filename = data.filename || '';
|
||||||
let compression = '__default__';
|
let compression = '__default__';
|
||||||
|
let needsFormat = false;
|
||||||
if (view.content === 'iso') {
|
if (view.content === 'iso') {
|
||||||
const matches = filename.match(/^(.+)\.(gz|lzo|zst|bz2)$/i);
|
const matches = filename.match(/^(.+)\.(gz|lzo|zst|bz2)$/i);
|
||||||
if (matches) {
|
if (matches) {
|
||||||
@@ -89,10 +91,12 @@ Ext.define('PVE.window.DownloadUrlToStorage', {
|
|||||||
compression = matches[2].toLowerCase();
|
compression = matches[2].toLowerCase();
|
||||||
}
|
}
|
||||||
} else if (view.content === 'import') {
|
} else if (view.content === 'import') {
|
||||||
if (filename.endsWith('.img')) {
|
// the extension does not tell the image format, the user has to select it
|
||||||
filename += '.raw';
|
needsFormat = filename.endsWith('.img');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
me.queriedName = filename;
|
||||||
|
me.getViewModel().set('needsFormat', needsFormat);
|
||||||
|
me.lookup('imageFormat').setValue(null);
|
||||||
|
|
||||||
view.setValues({
|
view.setValues({
|
||||||
filename,
|
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) {
|
hashChange: function (field) {
|
||||||
let checksum = Ext.getCmp('downloadUrlChecksum');
|
let checksum = Ext.getCmp('downloadUrlChecksum');
|
||||||
if (field.getValue() === '__default__') {
|
if (field.getValue() === '__default__') {
|
||||||
@@ -169,6 +179,22 @@ Ext.define('PVE.window.DownloadUrlToStorage', {
|
|||||||
return this.processRawValue(this.getRawValue())?.trim();
|
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: [
|
column1: [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user