From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH manager v4 1/2] fix #4849: download to storage: automatically dectect and configure compression
Date: Fri, 04 Aug 2023 13:53:48 +0200 [thread overview]
Message-ID: <1691149902.12mh76ajgb.astroid@yuna.none> (raw)
In-Reply-To: <20230801144604.760331-6-p.hufnagl@proxmox.com>
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ünbichler <f.gruenbichler@proxmox.com>
Tested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> Signed-off-by: Philipp Hufnagl <p.hufnagl@proxmox.com>
> ---
> 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
>
> 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 => 'boolean',
> optional => 1,
> default => 1,
> + },
> + 'detect-compression' => {
> + description => "If true an auto detect of used compression will be attempted",
> + type => 'boolean',
> + optional => 1,
> + default => 0,
> }
> },
> },
> @@ -1583,6 +1589,11 @@ __PACKAGE__->register_method({
> type => 'string',
> optional => 1,
> },
> + compression => {
> + type => 'string',
> + enum => $PVE::Storage::Plugin::KNOWN_COMPRESSION_FORMATS,
> + optional => 1,
> + },
> },
> },
> code => sub {
> @@ -1606,6 +1617,8 @@ __PACKAGE__->register_method({
> );
> }
>
> + my $detect_compression = $param->{'detect-compression'};
> +
> my $req = HTTP::Request->new(HEAD => $url);
> my $res = $ua->request($req);
>
> @@ -1614,7 +1627,7 @@ __PACKAGE__->register_method({
> my $size = $res->header("Content-Length");
> my $disposition = $res->header("Content-Disposition");
> my $type = $res->header("Content-Type");
> -
> + my $compression;
> my $filename;
>
> if ($disposition && ($disposition =~ m/filename="([^"]*)"/ || $disposition =~ m/filename=([^;]*)/)) {
> @@ -1628,10 +1641,16 @@ __PACKAGE__->register_method({
> $type = $1;
> }
>
> + if ($detect_compression && $filename =~ m!^((.+)\.(${\PVE::Storage::Plugin::COMPRESSOR_RE}))$!) {
> + $filename = $2;
> + $compression = $3;
> + }
> +
> my $ret = {};
> $ret->{filename} = $filename if $filename;
> $ret->{size} = $size + 0 if $size;
> $ret->{mimetype} = $type if $type;
> + $ret->{compression} = $compression if $compression;
>
> 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= \
> 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/form/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/window/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 === 'iso';
> + },
>
> urlCheck: function(field) {
> let me = 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 => {
> @@ -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 === 'iso') {
> + me.items[0].advancedColumn2.push(
> +
> + {
> + xtype: 'pveDecompressionSelector',
> + name: 'compression',
> + fieldLabel: gettext('Decompression algorithm'),
> + allowBlank: true,
> + hasNoneOption: true,
> + value: '__default__',
> + });
> + }
>
> me.callParent();
> },
> --
> 2.39.2
>
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
>
next prev parent reply other threads:[~2023-08-04 11:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 14:45 [pve-devel] [PATCH storage/manager/common v4 0/6] fix #4849: allow download of compressed ISOs Philipp Hufnagl
2023-08-01 14:45 ` [pve-devel] [PATCH storage v4 1/2] fix #4849: download-url: allow download and decompression " Philipp Hufnagl
2023-08-04 11:51 ` Fabian Grünbichler
2023-08-01 14:46 ` [pve-devel] [PATCH storage v4 2/2] fix whitespaces Philipp Hufnagl
2023-08-04 11:49 ` [pve-devel] applied: " Fabian Grünbichler
2023-08-01 14:46 ` [pve-devel] [PATCH common v4 1/2] fix #4849: download file from url: add opt parameter for a decompression command Philipp Hufnagl
2023-08-04 11:47 ` [pve-devel] applied: " Fabian Grünbichler
2023-08-01 14:46 ` [pve-devel] [PATCH common v4 2/2] fix whitespaces Philipp Hufnagl
2023-08-04 11:48 ` [pve-devel] applied: " Fabian Grünbichler
2023-08-01 14:46 ` [pve-devel] [PATCH manager v4 1/2] fix #4849: download to storage: automatically dectect and configure compression Philipp Hufnagl
2023-08-04 11:53 ` Fabian Grünbichler [this message]
2023-08-01 14:46 ` [pve-devel] [PATCH manager v4 2/2] fix whitespaces Philipp Hufnagl
2023-08-04 11:49 ` [pve-devel] applied: " Fabian Grünbichler
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=1691149902.12mh76ajgb.astroid@yuna.none \
--to=f.gruenbichler@proxmox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.