From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>
Subject: [pbs-devel] applied: [PATCH backup v3 1/3] use truncate whenever we create files
Date: Mon, 27 Jan 2025 13:27:35 +0100 [thread overview]
Message-ID: <1737980596.kue4kgi0fu.astroid@yuna.none> (raw)
In-Reply-To: <20250127121016.247973-1-m.sandoval@proxmox.com>
On January 27, 2025 1:10 pm, Maximiliano Sandoval wrote:
> Fixes the suspicious_open_options clippy lint, for example:
>
> ```
> warning: file opened with `create`, but `truncate` behavior not defined
> --> src/api2/tape/restore.rs:1713:18
> |
> 1713 | .create(true)
> | ^^^^^^^^^^^^- help: add: `.truncate(true)`
> |
> = help: if you intend to overwrite an existing file entirely, call `.truncate(true)`
> = help: if you instead know that you may want to keep some parts of the old file, call `.truncate(false)`
> = help: alternatively, use `.append(true)` to append to the file instead of overwriting it
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_open_options
> ```
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> Differences from v1:
> - Follow overwrite_flags in pxar extract
>
> src/api2/tape/restore.rs | 1 +
> src/server/sync.rs | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs
> index 93a6053b..2cc1baab 100644
> --- a/src/api2/tape/restore.rs
> +++ b/src/api2/tape/restore.rs
> @@ -1711,6 +1711,7 @@ fn try_restore_snapshot_archive<R: pxar::decoder::SeqRead>(
> let mut tmpfile = std::fs::OpenOptions::new()
> .write(true)
> .create(true)
> + .truncate(true)
> .read(true)
> .open(&tmp_path)
> .map_err(|err| format_err!("restore {:?} failed - {}", tmp_path, err))?;
> diff --git a/src/server/sync.rs b/src/server/sync.rs
> index 5e3fbdcd..4dd46c5a 100644
> --- a/src/server/sync.rs
> +++ b/src/server/sync.rs
> @@ -159,6 +159,7 @@ impl SyncSourceReader for RemoteSourceReader {
> let tmpfile = std::fs::OpenOptions::new()
> .write(true)
> .create(true)
> + .truncate(true)
> .read(true)
> .open(&tmp_path)?;
>
> --
> 2.39.5
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
>
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
prev parent reply other threads:[~2025-01-27 12:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-27 12:10 [pbs-devel] " Maximiliano Sandoval
2025-01-27 12:10 ` [pbs-devel] [PATCH backup v3 2/3] remove create & truncate when create_new is used Maximiliano Sandoval
2025-01-27 12:27 ` Fabian Grünbichler
2025-01-27 12:37 ` Maximiliano Sandoval
2025-01-27 12:10 ` [pbs-devel] [PATCH backup v3 3/3] pxar: extract: Follow overwrite_flags when opening file Maximiliano Sandoval
2025-01-27 12:27 ` [pbs-devel] applied: " Fabian Grünbichler
2025-01-27 12:27 ` Fabian Grünbichler [this message]
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=1737980596.kue4kgi0fu.astroid@yuna.none \
--to=f.gruenbichler@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