[pbs-devel] applied: [PATCH backup v3 3/3] pxar: extract: Follow overwrite_flags when opening file

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Jan 27 13:27:38 CET 2025


On January 27, 2025 1:10 pm, Maximiliano Sandoval wrote:
> Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
> ---
>  pbs-client/src/pxar/extract.rs | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --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 at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 




More information about the pbs-devel mailing list