all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Christian Ebner <c.ebner@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 2/2] fix: #4761: introduce overwrite bitflags for fine grained overwrites
Date: Fri, 4 Aug 2023 14:30:36 +0200	[thread overview]
Message-ID: <yc6u3syzvasqb2b3wgz6tfo7re2ezqk5erjcp4vijw7kybxaza@oqam5ltm5pgg> (raw)
In-Reply-To: <20230801103412.182490-3-c.ebner@proxmox.com>

This has some trailing whitespace and needs a `rustfmt`.

Also, see inline comments:

On Tue, Aug 01, 2023 at 12:34:12PM +0200, Christian Ebner wrote:
> Adds OverwriteFlags for granular control of which entry types should
> overwrite entries present on the filesystem during a restore.
> 
> The original overwrite flag is refactored in order to cover all of the
> other cases.
> 
> Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
> ---
> changes since v1:
> * rebased and refactored to current master
> 
>  pbs-client/src/catalog_shell.rs   |  9 ++++--
>  pbs-client/src/pxar/extract.rs    | 47 +++++++++++++++++++++++--------
>  pbs-client/src/pxar/mod.rs        |  2 +-
>  proxmox-backup-client/src/main.rs | 28 +++++++++++++++++-
>  pxar-bin/src/main.rs              | 32 +++++++++++++++++++--
>  5 files changed, 101 insertions(+), 17 deletions(-)
> 
(...)
> diff --git a/pbs-client/src/pxar/extract.rs b/pbs-client/src/pxar/extract.rs
> index c1e7b417..6faf0b54 100644
> --- a/pbs-client/src/pxar/extract.rs
> +++ b/pbs-client/src/pxar/extract.rs
> @@ -9,6 +9,7 @@ use std::path::{Path, PathBuf};
>  use std::sync::{Arc, Mutex};
>  
>  use anyhow::{bail, format_err, Context, Error};
> +use bitflags::bitflags;
>  use nix::dir::Dir;
>  use nix::fcntl::OFlag;
>  use nix::sys::stat::Mode;
> @@ -33,10 +34,34 @@ pub struct PxarExtractOptions<'a> {
>      pub match_list: &'a [MatchEntry],
>      pub extract_match_default: bool,
>      pub allow_existing_dirs: bool,
> -    pub overwrite: bool,
> +    pub overwrite_flags: OverwriteFlags,
>      pub on_error: Option<ErrorHandler>,
>  }
>  
> +
> +bitflags! {
> +    pub struct OverwriteFlags: u8 {
> +        /// Disable all
> +        const NONE = 0x0;

bitflags provides a `OverwriteFlags::empty()`, so I'd drop the `NONE`
variant

> +        /// Overwrite existing entries file content 
> +        const FILE = 0x1;
> +        /// Overwrite existing entry with symlink
> +        const SYMLINK = 0x2;
> +        /// Overwrite existing entry with hardlink
> +        const HARDLINK = 0x4;
> +        /// Enable all
> +        const ALL = OverwriteFlags::FILE.bits()
> +            | OverwriteFlags::SYMLINK.bits()
> +            | OverwriteFlags::HARDLINK.bits();

and bitflags also provides a `OverwriteFlags::all()`, so I'd drop `ALL`
as well ;-)

> +    }
> +}
> +
> +impl Default for OverwriteFlags {
> +    fn default() -> Self {
> +        OverwriteFlags::NONE

since this is `0`, you can just `derive(Default)` instead

> +    }
> +}
> +
>  pub type ErrorHandler = Box<dyn FnMut(Error) -> Result<(), Error> + Send>;
>  
>  pub fn extract_archive<T, F>(
> @@ -141,7 +166,7 @@ where
(...)

Otherwise LGTM




      reply	other threads:[~2023-08-04 12:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01 10:34 [pbs-devel] [PATCH v2 proxmox-backup 0/2] Introduce bitflags for overwrite Christian Ebner
2023-08-01 10:34 ` [pbs-devel] [PATCH v2 proxmox-backup 1/2] fix: #4761: unlink existing entries for hard/symlinks when overwrite Christian Ebner
2023-08-04 12:20   ` Wolfgang Bumiller
2023-08-04 12:32     ` Wolfgang Bumiller
2023-08-01 10:34 ` [pbs-devel] [PATCH v2 proxmox-backup 2/2] fix: #4761: introduce overwrite bitflags for fine grained overwrites Christian Ebner
2023-08-04 12:30   ` Wolfgang Bumiller [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=yc6u3syzvasqb2b3wgz6tfo7re2ezqk5erjcp4vijw7kybxaza@oqam5ltm5pgg \
    --to=w.bumiller@proxmox.com \
    --cc=c.ebner@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal