public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>
Subject: Re: [pbs-devel] [PATCH v6 proxmox-backup 0/4] fix #2996: client: allow optional match patterns for restore
Date: Mon, 25 Nov 2024 12:29:21 +0100	[thread overview]
Message-ID: <1732534011.hf3x11ngo1.astroid@yuna.none> (raw)
In-Reply-To: <20241112104316.206282-1-c.ebner@proxmox.com>

Consider this

Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>

but I'd like to add the following on-top, unless you object:

Subject: [PATCH proxmox-backup] api types: replace PathPatterns with Vec<PathPattern>

PathPatterns is hard to distinguish from PathPattern, so would need to be
renamed anyway.. but there isn't really a reason to define a separate API type
just for this.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 pbs-api-types/src/pathpatterns.rs | 27 +--------------------------
 proxmox-backup-client/src/main.rs |  8 ++++++--
 pxar-bin/src/main.rs              |  9 +++++++--
 3 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/pbs-api-types/src/pathpatterns.rs b/pbs-api-types/src/pathpatterns.rs
index c40926a44..505ecc8aa 100644
--- a/pbs-api-types/src/pathpatterns.rs
+++ b/pbs-api-types/src/pathpatterns.rs
@@ -1,4 +1,4 @@
-use proxmox_schema::{const_regex, ApiStringFormat, ApiType, ArraySchema, Schema, StringSchema};
+use proxmox_schema::{const_regex, ApiStringFormat, ApiType, Schema, StringSchema};
 
 use serde::{Deserialize, Serialize};
 
@@ -13,12 +13,6 @@ pub const PATH_PATTERN_SCHEMA: Schema =
         .format(&PATH_PATTERN_FORMAT)
         .schema();
 
-pub const PATH_PATTERN_LIST_SCHEMA: Schema = ArraySchema::new(
-    "List of paths or match patterns for matching filenames.",
-    &PATH_PATTERN_SCHEMA,
-)
-.schema();
-
 #[derive(Default, Deserialize, Serialize)]
 /// Path or path pattern for filename matching
 pub struct PathPattern {
@@ -34,22 +28,3 @@ impl AsRef<[u8]> for PathPattern {
         self.pattern.as_bytes()
     }
 }
-
-#[derive(Default, Deserialize, Serialize)]
-/// Array of paths and/or path patterns for filename matching
-pub struct PathPatterns {
-    patterns: Vec<PathPattern>,
-}
-
-impl ApiType for PathPatterns {
-    const API_SCHEMA: Schema = PATH_PATTERN_LIST_SCHEMA;
-}
-
-impl IntoIterator for PathPatterns {
-    type Item = PathPattern;
-    type IntoIter = std::vec::IntoIter<PathPattern>;
-
-    fn into_iter(self) -> Self::IntoIter {
-        self.patterns.into_iter()
-    }
-}
diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index cfeed77d7..89f91e2b5 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -26,7 +26,7 @@ use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation};
 
 use pbs_api_types::{
     ArchiveType, Authid, BackupArchiveName, BackupDir, BackupGroup, BackupNamespace, BackupPart,
-    BackupType, ClientRateLimitConfig, CryptMode, Fingerprint, GroupListItem, PathPatterns,
+    BackupType, ClientRateLimitConfig, CryptMode, Fingerprint, GroupListItem, PathPattern,
     PruneJobOptions, PruneListItem, RateLimitConfig, SnapshotListItem, StorageStatus,
     BACKUP_ID_SCHEMA, BACKUP_NAMESPACE_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA,
     CATALOG_NAME, ENCRYPTED_KEY_BLOB_NAME, MANIFEST_BLOB_NAME,
@@ -1407,7 +1407,11 @@ We do not extract '.pxar' archives when writing to standard output.
                 flatten: true,
             },
             pattern: {
-                type: PathPatterns,
+                type: Array,
+                items: {
+                    type: PathPattern,
+                },
+                description: "Path or match pattern to limit files that get restored.",
                 optional: true,
             },
             "allow-existing-dirs": {
diff --git a/pxar-bin/src/main.rs b/pxar-bin/src/main.rs
index eb3580d92..7dff1e38c 100644
--- a/pxar-bin/src/main.rs
+++ b/pxar-bin/src/main.rs
@@ -13,7 +13,8 @@ use serde_json::Value;
 use tokio::signal::unix::{signal, SignalKind};
 
 use pathpatterns::{MatchEntry, MatchType, PatternFlag};
-use pbs_api_types::PathPatterns;
+
+use pbs_api_types::PathPattern;
 use pbs_client::pxar::tools::format_single_line_entry;
 use pbs_client::pxar::{
     Flags, OverwriteFlags, PxarExtractOptions, PxarWriters, ENCODER_MAX_ENTRIES,
@@ -55,8 +56,12 @@ fn extract_archive_from_reader<R: std::io::Read>(
                 description: "Archive name.",
             },
             pattern: {
-                type: PathPatterns,
+                type: Array,
+                items: {
+                    type: PathPattern,
+                },
                 optional: true,
+                description: "Path or match pattern to limit files that get restored.",
             },
             target: {
                 description: "Target directory",
-- 
2.39.5




On November 12, 2024 11:43 am, Christian Ebner wrote:
> This patches implement the api types to allow input validation for
> pathpatterns and reuse them in the pxar-bin, the catalog shell as
> well as the newly exposed optional restore patterns to the backup
> clients restore command.
> 
> Patterns are parsed and passed along to the preexisting restore
> logic via the `PxarExtractOptions`.
> 
> To correctly work also with split pxar archives, this patches depend
> on the following patch being applied to the pxar repo first:
> https://lore.proxmox.com/pbs-devel/20240918150047.485551-1-c.ebner@proxmox.com/
> 
> changes since version 5:
> - rebased onto current master
> 
> changes since version 4:
> - rebased onto current master
> - fixed passing patterns via cli for pxar extract
> 
> changes since version 3:
> - s/matches/patterns for bail message, thanks for testing and
>   catching this Gabriel!
> 
> changes since version 2:
> - added API types as suggested
> - reuse same API types for proxmox-backup-client catalog shell and
>   restore as well as the pxar extract
> - use simple reference instead of `as_slice()` when passing vector of
>   patterns
> 
> Link to bugtracker issue:
> https://bugzilla.proxmox.com/show_bug.cgi?id=2996
> 
> Christian Ebner (4):
>   api-types: implement dedicated api type for match patterns
>   pxar: bin: use dedicated api type for restore pattern
>   client: catalog shell: use dedicated api type for patterns
>   fix #2996: client: allow optional match patterns for restore
> 
>  pbs-api-types/src/lib.rs          |  3 ++
>  pbs-api-types/src/pathpatterns.rs | 55 +++++++++++++++++++++++++++++++
>  pbs-client/src/catalog_shell.rs   |  7 ++--
>  proxmox-backup-client/src/main.rs | 29 +++++++++++++---
>  pxar-bin/Cargo.toml               |  1 +
>  pxar-bin/src/main.rs              | 26 +++++++--------
>  6 files changed, 99 insertions(+), 22 deletions(-)
>  create mode 100644 pbs-api-types/src/pathpatterns.rs
> 
> -- 
> 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

  parent reply	other threads:[~2024-11-25 11:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12 10:43 Christian Ebner
2024-11-12 10:43 ` [pbs-devel] [PATCH v6 proxmox-backup 1/4] api-types: implement dedicated api type for match patterns Christian Ebner
2024-11-12 10:43 ` [pbs-devel] [PATCH v6 proxmox-backup 2/4] pxar: bin: use dedicated api type for restore pattern Christian Ebner
2024-11-12 10:43 ` [pbs-devel] [PATCH v6 proxmox-backup 3/4] client: catalog shell: use dedicated api type for patterns Christian Ebner
2024-11-12 10:43 ` [pbs-devel] [PATCH v6 proxmox-backup 4/4] fix #2996: client: allow optional match patterns for restore Christian Ebner
2024-11-25 11:29 ` Fabian Grünbichler [this message]
2024-11-25 12:09   ` [pbs-devel] [PATCH v6 proxmox-backup 0/4] " Christian Ebner
2024-11-25 13:10     ` [pbs-devel] applied-series: " 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=1732534011.hf3x11ngo1.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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal