http client: suppress "storing login ticket"-error when not using a TTY

as a stop-gap measure. Otherwise, task logs for PVE backups started
via non-CLI will have the message
> storing login ticket failed: $XDG_RUNTIME_DIR must be set
show up when running a proxmox-backup-client command (e.g. setting
notes and when uploading the log). This is confusing to users[0].

[0]: https://forum.proxmox.com/threads/120492/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2023-01-05 11:19:32 +01:00 committed by Wolfgang Bumiller
parent a2055c38fe
commit 73809d55b7

View File

@ -458,9 +458,11 @@ impl HttpClient {
&auth.ticket, &auth.ticket,
&auth.token, &auth.token,
) { ) {
if tty::stdout_isatty() {
log::error!("storing login ticket failed: {}", err); log::error!("storing login ticket failed: {}", err);
} }
} }
}
*auth2.write().unwrap() = auth; *auth2.write().unwrap() = auth;
} }
Err(err) => { Err(err) => {
@ -494,9 +496,11 @@ impl HttpClient {
&auth.ticket, &auth.ticket,
&auth.token, &auth.token,
) { ) {
if tty::stdout_isatty() {
log::error!("storing login ticket failed: {}", err); log::error!("storing login ticket failed: {}", err);
} }
} }
}
*authinfo.write().unwrap() = auth; *authinfo.write().unwrap() = auth;
tokio::spawn(renewal_future); tokio::spawn(renewal_future);
} }