From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH backup v3 3/3] pxar: extract: Follow overwrite_flags when opening file
Date: Mon, 27 Jan 2025 13:10:16 +0100 [thread overview]
Message-ID: <20250127121016.247973-3-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20250127121016.247973-1-m.sandoval@proxmox.com>
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
| 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
--git a/pbs-client/src/pxar/extract.rs b/pbs-client/src/pxar/extract.rs
index 64754006..6b0e6302 100644
--- a/pbs-client/src/pxar/extract.rs
+++ b/pbs-client/src/pxar/extract.rs
@@ -133,9 +133,18 @@ where
if let Some(ref path) = options.prelude_path {
if let Some(entry) = prelude {
- let mut prelude_file = OpenOptions::new()
- .create(true)
- .write(true)
+ let overwrite = options.overwrite_flags.contains(OverwriteFlags::FILE);
+
+ let mut open_options = OpenOptions::new();
+ open_options.write(true);
+ if overwrite {
+ open_options.create(true);
+ open_options.truncate(true);
+ } else {
+ open_options.create_new(true);
+ }
+
+ let mut prelude_file = open_options
.open(path)
.with_context(|| format!("error creating prelude file '{path:?}'"))?;
if let pxar::EntryKind::Prelude(ref prelude) = entry.kind() {
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2025-01-27 12:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-27 12:10 [pbs-devel] [PATCH backup v3 1/3] use truncate whenever we create files 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 ` Maximiliano Sandoval [this message]
2025-01-27 12:27 ` [pbs-devel] applied: [PATCH backup v3 3/3] pxar: extract: Follow overwrite_flags when opening file Fabian Grünbichler
2025-01-27 12:27 ` [pbs-devel] applied: [PATCH backup v3 1/3] use truncate whenever we create files Fabian Grünbichler
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=20250127121016.247973-3-m.sandoval@proxmox.com \
--to=m.sandoval@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.