From: "Shannon Sterz" <s.sterz@proxmox.com>
To: "Michael Köppl" <m.koeppl@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox-backup v4 2/3] fix #7400: api: gracefully handle corrupted job statefiles
Date: Mon, 13 Apr 2026 15:02:41 +0200 [thread overview]
Message-ID: <DHS1PRB2G8RZ.6Z5N5Q0DWEAX@proxmox.com> (raw)
In-Reply-To: <DHS1L8I53P0E.7CPUTOGYAFSB@proxmox.com>
-->8 snip 8<--
>>> @@ -191,11 +197,23 @@ impl JobState {
>>> /// This does not update the state in the file.
>>> pub fn load(jobtype: &str, jobname: &str) -> Result<Self, Error> {
>>> if let Some(state) = file_read_optional_string(get_path(jobtype, jobname))? {
>>> - match serde_json::from_str(&state)? {
>>> + let job_state = match serde_json::from_str(&state) {
>>> + Ok(parsed_state) => parsed_state,
>>> + Err(err) => {
>>> + log::error!("could not parse statefile for {jobname}: {err}");
>>> + return Ok(JobState::Unknown);
>>> + }
>>
>> kind of a stylistic choice, but i think the following might be slightly
>> neater here:
>>
>> ```
>> let Ok(job_sate) = serde_json::from_str(&state) else {
>> log::error!("could not parse statefile for {jobname}: {err}");
>> return Ok(JobState::Unknown);
>> }
>> ```
>
> AFAIK there's no way to get the error with let-else? It's why I chose
> the regular approach with match.
>
ah yeah sorry, missed that. and yeah true, you can't do that without
assigning the return value of the `from_str` call in between.
-->8 snip 8<--
next prev parent reply other threads:[~2026-04-13 13:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 13:26 [PATCH proxmox-backup v4 0/3] fix #7400: improve handling of " Michael Köppl
2026-04-03 13:26 ` [PATCH proxmox-backup v4 1/3] api: move statefile loading into compute_schedule_status Michael Köppl
2026-04-03 13:26 ` [PATCH proxmox-backup v4 2/3] fix #7400: api: gracefully handle corrupted job statefiles Michael Köppl
2026-04-09 10:09 ` Shannon Sterz
2026-04-13 12:56 ` Michael Köppl
2026-04-13 13:02 ` Shannon Sterz [this message]
2026-04-03 13:26 ` [PATCH proxmox-backup v4 3/3] fix #7400: proxy: self-heal " Michael Köppl
2026-04-13 13:21 ` superseded: [PATCH proxmox-backup v4 0/3] fix #7400: improve handling of " Michael Köppl
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=DHS1PRB2G8RZ.6Z5N5Q0DWEAX@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=m.koeppl@proxmox.com \
--cc=pbs-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