public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Michal Fox <me@dualfroz.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH manager 2/2] fix #8015: ui: download url: let the user choose the .img image format
Date: Tue, 29 Sep 2026 15:58:40 +0200	[thread overview]
Message-ID: <20260929135840.2748665-3-me@dualfroz.com> (raw)
In-Reply-To: <20260929135840.2748665-1-me@dualfroz.com>

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>
---
 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 f1c4392c..be31fb59 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: [
                 {
-- 
2.43.0




  parent reply	other threads:[~2026-09-30  7:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 13:58 [PATCH manager 0/2] fix #8015: ui: let the user choose the .img image format for import Michal Fox
2026-09-29 13:58 ` [PATCH manager 1/2] fix #8015: ui: upload: let the user choose the .img image format Michal Fox
2026-09-29 13:58 ` Michal Fox [this message]
2026-09-30 10:27 ` applied: [PATCH manager 0/2] fix #8015: ui: let the user choose the .img image format for import Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260929135840.2748665-3-me@dualfroz.com \
    --to=me@dualfroz.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal