From: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 1/1] fix #3971: Revised task log API call when parameter 'limit' is 0
Date: Tue, 26 Apr 2022 14:35:39 +0200 [thread overview]
Message-ID: <20220426123542.154739-5-d.tschlatscher@proxmox.com> (raw)
In-Reply-To: <20220426123542.154739-1-d.tschlatscher@proxmox.com>
The API call for fetching a tasklog with limit=0 now returns the whole
log as a file stream rather than reading all lines in memory and then
transfering them in JSON format. The behaviour when the url parameter
limit is undefined or not 0 is the same as before, in accordance
with the API specification.
Also replaced the system-report and PBSEdit file download with a call
to the newly added downloadStringAsFile() function in the proxmox-
widget-toolkit repository in the Utils class (Proxmox.Utils).
Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
---
PVE/API2/Tasks.pm | 13 ++++++++++---
www/manager6/node/Subscription.js | 20 ++++----------------
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/PVE/API2/Tasks.pm b/PVE/API2/Tasks.pm
index 9cd1e56b..5572f826 100644
--- a/PVE/API2/Tasks.pm
+++ b/PVE/API2/Tasks.pm
@@ -5,6 +5,7 @@ use warnings;
use POSIX;
use IO::File;
use File::ReadBackwards;
+use File::stat;
use PVE::Tools;
use PVE::SafeSyslog;
use PVE::RESTHandler;
@@ -387,11 +388,17 @@ __PACKAGE__->register_method({
$rpcenv->check($user, "/nodes/$node", [ 'Sys.Audit' ]);
}
- my ($count, $lines) = PVE::Tools::dump_logfile($filename, $start, $limit);
+ if ($limit == 0) {
+ # TCP Max Transfer Unit size is 1500, compression for lower numbers has no effect
+ my $use_compression = stat($filename)->size > 1500;
+ return PVE::Tools::stream_logfile($filename, $use_compression, $param->{upid});
+ } else {
+ my ($count, $lines) = PVE::Tools::dump_logfile($filename, $start, $limit);
- $rpcenv->set_result_attrib('total', $count);
+ $rpcenv->set_result_attrib('total', $count);
- return $lines;
+ return $lines;
+ }
}});
diff --git a/www/manager6/node/Subscription.js b/www/manager6/node/Subscription.js
index 2558f523..147eeed1 100644
--- a/www/manager6/node/Subscription.js
+++ b/www/manager6/node/Subscription.js
@@ -58,22 +58,10 @@ Ext.define('PVE.node.Subscription', {
{
text: gettext('Download'),
handler: function() {
- var fileContent = Ext.String.htmlDecode(reportWindow.getComponent('system-report-view').html);
- var fileName = getReportFileName();
-
- // Internet Explorer
- if (window.navigator.msSaveOrOpenBlob) {
- navigator.msSaveOrOpenBlob(new Blob([fileContent]), fileName);
- } else {
- var element = document.createElement('a');
- element.setAttribute('href', 'data:text/plain;charset=utf-8,' +
- encodeURIComponent(fileContent));
- element.setAttribute('download', fileName);
- element.style.display = 'none';
- document.body.appendChild(element);
- element.click();
- document.body.removeChild(element);
- }
+ let fileContent = Ext.String.htmlDecode(reportWindow.getComponent('system-report-view').html);
+ let fileName = getReportFileName();
+
+ Proxmox.Utils.downloadStringAsFile(fileContent, fileName);
},
},
],
--
2.30.2
next prev parent reply other threads:[~2022-04-26 12:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-26 12:35 [pve-devel] [PATCH http/common/manager/wt/proxmox-backup/pmg] Tasklog download button Daniel Tschlatscher
2022-04-26 12:35 ` [pve-devel] [PATCH proxmox-backup 1/1] fix #3971: tasklog download in the backup server backend Daniel Tschlatscher
2022-04-26 12:35 ` [pve-devel] [PATCH http-server 1/1] fix #3971: Make tasklog downloadable Daniel Tschlatscher
2022-04-26 12:35 ` [pve-devel] [PATCH common 1/1] fix #3971: Create log file stream for download Daniel Tschlatscher
2022-04-27 14:37 ` Thomas Lamprecht
2022-04-26 12:35 ` Daniel Tschlatscher [this message]
2022-04-26 12:35 ` [pve-devel] [PATCH pmg-api 1/1] fix #3971: Download button in TaskViewer for PMG Daniel Tschlatscher
2022-04-26 12:35 ` [pve-devel] [PATCH widget-toolkit 1/1] fix #3971: Download button in the TaskViewer Daniel Tschlatscher
2022-04-26 12:35 ` [pve-devel] [PATCH pmg-gui 1/1] Replaced the system-report file download implementation Daniel Tschlatscher
2022-06-28 11:23 ` [pve-devel] [PATCH http/common/manager/wt/proxmox-backup/pmg] Tasklog download button Daniel Tschlatscher
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=20220426123542.154739-5-d.tschlatscher@proxmox.com \
--to=d.tschlatscher@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox