[pve-devel] [PATCH manager v8 1/2] fix #4849: api: download to storage: automatically dectect and configure compression

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Sep 27 19:19:06 CEST 2023


Am 27/09/2023 um 10:57 schrieb Philipp Hufnagl:
> On 9/27/23 10:33, Thomas Lamprecht wrote:
>> FYI, I have a pretty much done patch for this already here, so if
>> you did not have anything (close to) already finished, I could push
>> that out – just mentioning to avoid potential duplicate work.
> 
> 
> I have nothing close. Sorry for the inconvenience and thank you for
> fixing.

OK, I now applied below change for doing this in the frontend and
reverted the API change. FWIW, this is not 100% semantically the same,
as I now try to match the file-extension with the case-insensitive flag
to allow matching a, e.g., ISO.GZ too.

----8<----
diff --git a/www/manager6/window/DownloadUrlToStorage.js b/www/manager6/window/DownloadUrlToStorage.js
index 481cb2ed..335d6aa6 100644
--- a/www/manager6/window/DownloadUrlToStorage.js
+++ b/www/manager6/window/DownloadUrlToStorage.js
@@ -66,7 +66,6 @@ Ext.define('PVE.window.DownloadUrlToStorage', {
                params: {
                    url: queryParam.url,
                    'verify-certificates': queryParam['verify-certificates'],
-                   'detect-compression': view.content === 'iso' ? 1 : 0,
                },
                waitMsgTarget: view,
                failure: res => {
@@ -81,11 +80,22 @@ Ext.define('PVE.window.DownloadUrlToStorage', {
                    urlField.validate();
 
                    let data = res.result.data;
+
+                   let filename = data.filename || "";
+                   let compression = '__default__';
+                   if (view.content === 'iso') {
+                       const matches = filename.match(/^(.+)\.(gz|lzo|zst)$/i);
+                       if (matches) {
+                           filename = matches[1];
+                           compression = matches[2];
+                       }
+                   }
+
                    view.setValues({
-                       filename: data.filename || "",
+                       filename,
+                       compression,
                        size: (data.size && Proxmox.Utils.format_size(data.size)) || gettext("Unknown"),
                        mimetype: data.mimetype || gettext("Unknown"),
-                       compression: data.compression || '__default__',
                    });
                },
            });





More information about the pve-devel mailing list