mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-03-05 20:58:33 +03:00
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>
This commit is contained in:
parent
1bb680017b
commit
2009d8de41
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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": {
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user