From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CD9249BBB for ; Fri, 4 Aug 2023 13:53:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AFA1AE698 for ; Fri, 4 Aug 2023 13:53:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 4 Aug 2023 13:53:54 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B5E8B40BF2 for ; Fri, 4 Aug 2023 13:53:54 +0200 (CEST) Date: Fri, 04 Aug 2023 13:53:48 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20230801144604.760331-1-p.hufnagl@proxmox.com> <20230801144604.760331-6-p.hufnagl@proxmox.com> In-Reply-To: <20230801144604.760331-6-p.hufnagl@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1691149902.12mh76ajgb.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.068 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [nodes.pm, proxmox.com] Subject: Re: [pve-devel] [PATCH manager v4 1/2] fix #4849: download to storage: automatically dectect and configure compression X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Aug 2023 11:53:56 -0000 On August 1, 2023 4:46 pm, Philipp Hufnagl wrote: same here - please add a commit message! with one nit below that could be folded in together with the commit message, after pve-common and pve-storage have been bumped, since this one requires their changes and a corresponding bump in d/control: Reviewed-by: Fabian Gr=C3=BCnbichler Tested-by: Fabian Gr=C3=BCnbichler > Signed-off-by: Philipp Hufnagl > --- > PVE/API2/Nodes.pm | 21 ++++++++++++++++++++- > www/manager6/Makefile | 1 + > www/manager6/form/DecompressionSelector.js | 13 +++++++++++++ > www/manager6/window/DownloadUrlToStorage.js | 17 +++++++++++++++++ > 4 files changed, 51 insertions(+), 1 deletion(-) > create mode 100644 www/manager6/form/DecompressionSelector.js >=20 > diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm > index 9269694d..2bae4e6f 100644 > --- a/PVE/API2/Nodes.pm > +++ b/PVE/API2/Nodes.pm > @@ -1564,6 +1564,12 @@ __PACKAGE__->register_method({ > type =3D> 'boolean', > optional =3D> 1, > default =3D> 1, > + }, > + 'detect-compression' =3D> { > + description =3D> "If true an auto detect of used compression will be a= ttempted", > + type =3D> 'boolean', > + optional =3D> 1, > + default =3D> 0, > } > }, > }, > @@ -1583,6 +1589,11 @@ __PACKAGE__->register_method({ > type =3D> 'string', > optional =3D> 1, > }, > + compression =3D> { > + type =3D> 'string', > + enum =3D> $PVE::Storage::Plugin::KNOWN_COMPRESSION_FORMATS, > + optional =3D> 1, > + }, > }, > }, > code =3D> sub { > @@ -1606,6 +1617,8 @@ __PACKAGE__->register_method({ > ); > } > =20 > + my $detect_compression =3D $param->{'detect-compression'}; > + > my $req =3D HTTP::Request->new(HEAD =3D> $url); > my $res =3D $ua->request($req); > =20 > @@ -1614,7 +1627,7 @@ __PACKAGE__->register_method({ > my $size =3D $res->header("Content-Length"); > my $disposition =3D $res->header("Content-Disposition"); > my $type =3D $res->header("Content-Type"); > - > + my $compression; > my $filename; > =20 > if ($disposition && ($disposition =3D~ m/filename=3D"([^"]*)"/ || $disp= osition =3D~ m/filename=3D([^;]*)/)) { > @@ -1628,10 +1641,16 @@ __PACKAGE__->register_method({ > $type =3D $1; > } > =20 > + if ($detect_compression && $filename =3D~ m!^((.+)\.(${\PVE::Storage::P= lugin::COMPRESSOR_RE}))$!) { > + $filename =3D $2; > + $compression =3D $3; > + } > + > my $ret =3D {}; > $ret->{filename} =3D $filename if $filename; > $ret->{size} =3D $size + 0 if $size; > $ret->{mimetype} =3D $type if $type; > + $ret->{compression} =3D $compression if $compression; > =20 > return $ret; > }}); > diff --git a/www/manager6/Makefile b/www/manager6/Makefile > index 7ec9d7a5..42a27548 100644 > --- a/www/manager6/Makefile > +++ b/www/manager6/Makefile > @@ -34,6 +34,7 @@ JSSRC=3D \ > form/ContentTypeSelector.js \ > form/ControllerSelector.js \ > form/DayOfWeekSelector.js \ > + form/DecompressionSelector.js \ > form/DiskFormatSelector.js \ > form/DiskStorageSelector.js \ > form/EmailNotificationSelector.js \ > diff --git a/www/manager6/form/DecompressionSelector.js b/www/manager6/fo= rm/DecompressionSelector.js > new file mode 100644 > index 00000000..b85e050c > --- /dev/null > +++ b/www/manager6/form/DecompressionSelector.js > @@ -0,0 +1,13 @@ > +Ext.define('PVE.form.DecompressionSelector', { > + extend: 'Proxmox.form.KVComboBox', > + alias: ['widget.pveDecompressionSelector'], > + config: { > + deleteEmpty: false, > + }, > + comboItems: [ > + ['__default__', Proxmox.Utils.noneText], nit: this should be NoneText , not noneText, to get the right capitalization. > + ['lzo', 'LZO'], > + ['gz', 'GZIP'], > + ['zst', 'ZSTD'], > + ], > +}); > diff --git a/www/manager6/window/DownloadUrlToStorage.js b/www/manager6/w= indow/DownloadUrlToStorage.js > index 48543d28..7a472ce9 100644 > --- a/www/manager6/window/DownloadUrlToStorage.js > +++ b/www/manager6/window/DownloadUrlToStorage.js > @@ -49,6 +49,9 @@ Ext.define('PVE.window.DownloadUrlToStorage', { > vm.set('size', '-'); > vm.set('mimetype', '-'); > }, > + decompressionPossible: function() { > + return this.view.content =3D=3D=3D 'iso'; > + }, > =20 > urlCheck: function(field) { > let me =3D this; > @@ -66,6 +69,7 @@ Ext.define('PVE.window.DownloadUrlToStorage', { > params: { > url: queryParam.url, > 'verify-certificates': queryParam['verify-certificates'], > + 'detect-compression': me.decompressionPossible() ? 1 : 0, > }, > waitMsgTarget: view, > failure: res =3D> { > @@ -84,6 +88,7 @@ Ext.define('PVE.window.DownloadUrlToStorage', { > filename: data.filename || "", > size: (data.size && Proxmox.Utils.format_size(data.size)) || gettext(= "Unknown"), > mimetype: data.mimetype || gettext("Unknown"), > + compression: data.compression || '__default__', > }); > }, > }); > @@ -223,6 +228,18 @@ Ext.define('PVE.window.DownloadUrlToStorage', { > if (!me.storage) { > throw "no storage ID specified"; > } > + if (me.content =3D=3D=3D 'iso') { > + me.items[0].advancedColumn2.push( > + > + { > + xtype: 'pveDecompressionSelector', > + name: 'compression', > + fieldLabel: gettext('Decompression algorithm'), > + allowBlank: true, > + hasNoneOption: true, > + value: '__default__', > + }); > + } > =20 > me.callParent(); > }, > --=20 > 2.39.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20