From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 690579C76 for ; Fri, 4 Aug 2023 14:31:08 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 42713ECA1 for ; Fri, 4 Aug 2023 14:30:38 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 4 Aug 2023 14:30:37 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 86A7440C5C for ; Fri, 4 Aug 2023 14:30:37 +0200 (CEST) Date: Fri, 4 Aug 2023 14:30:36 +0200 From: Wolfgang Bumiller To: Christian Ebner Cc: pbs-devel@lists.proxmox.com Message-ID: References: <20230801103412.182490-1-c.ebner@proxmox.com> <20230801103412.182490-3-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230801103412.182490-3-c.ebner@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.114 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [extract.rs, main.rs, mod.rs] Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 2/2] fix: #4761: introduce overwrite bitflags for fine grained overwrites X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Aug 2023 12:31:08 -0000 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 > --- > 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, > } > > + > +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 Result<(), Error> + Send>; > > pub fn extract_archive( > @@ -141,7 +166,7 @@ where (...) Otherwise LGTM