From: Stefan Sterz <s.sterz@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api] fix #4521: api/tasks: replace upid as filename for task log downloads
Date: Thu, 9 Feb 2023 12:41:23 +0100 [thread overview]
Message-ID: <20230209114123.500907-1-s.sterz@proxmox.com> (raw)
previously the upid would just be used without a file extension when
downloading a task log. this lead to rather strange filenames that
appeared unfamiliar to users as the upid is not very prevalent in the
gui. set a proper file name based on the node name, worker type and a
time stamp instead. also add the ".log" file extension to indicate
that these files contain logs.
Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
---
src/PMG/API2/Tasks.pm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/PMG/API2/Tasks.pm b/src/PMG/API2/Tasks.pm
index d855507..c2fb6a7 100644
--- a/src/PMG/API2/Tasks.pm
+++ b/src/PMG/API2/Tasks.pm
@@ -292,13 +292,16 @@ __PACKAGE__->register_method({
open($fh, '<', $filename) or die "Could not open file '$filename' - $!\n";
}
+ my $task_time = strftime('%FT%TZ', gmtime($task->{starttime}));
+ my $download_name = 'task-'.$task->{node}.'-'.$task->{type}.'-'.$task_time.'.log';
+
return {
download => {
fh => $fh,
stream => 1,
'content-encoding' => $use_compression ? 'gzip' : undef,
'content-type' => "text/plain",
- 'content-disposition' => "attachment; filename=\"".$param->{upid}."\"",
+ 'content-disposition' => "attachment; filename=\"".$download_name."\"",
},
},
} else {
--
2.30.2
next reply other threads:[~2023-02-09 11:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 11:41 Stefan Sterz [this message]
2023-03-21 12:10 ` [pmg-devel] applied: " Thomas Lamprecht
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=20230209114123.500907-1-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pmg-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