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 ED4087A499 for ; Fri, 7 May 2021 12:51:10 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EB11929B3F for ; Fri, 7 May 2021 12:51:10 +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 id 5D01D29B31 for ; Fri, 7 May 2021 12:51:10 +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 36BFA42B32 for ; Fri, 7 May 2021 12:51:10 +0200 (CEST) To: Proxmox Backup Server development discussion , Dominik Csapak References: <20210506122008.11297-1-d.csapak@proxmox.com> <20210506122008.11297-3-d.csapak@proxmox.com> From: Dietmar Maurer Message-ID: <32c1f939-9634-5a16-f504-1d17972eef76@proxmox.com> Date: Fri, 7 May 2021 12:51:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210506122008.11297-3-d.csapak@proxmox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-SPAM-LEVEL: Spam detection results: 0 AWL 0.227 Adjusted score from AWL reputation of From: address 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [backup.rs, mod.rs] Subject: [pbs-devel] applied: [PATCH proxmox-backup v3 2/7] api2/types: add TAPE_RESTORE_SNAPSHOT_SCHEMA 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, 07 May 2021 10:51:11 -0000 applied with a cleanup on top: I moved all api related type/regx definition from backup_info.rs to src/api2/types/mod.rs On 5/6/21 2:20 PM, Dominik Csapak wrote: > which is 'store:type/id/time' > > needed to refactor SNAPSHOT_PATH_REGEX_STR from backup_info > > Signed-off-by: Dominik Csapak > --- > src/api2/types/mod.rs | 11 +++++++++++ > src/backup.rs | 1 + > src/backup/backup_info.rs | 9 ++++++++- > 3 files changed, 20 insertions(+), 1 deletion(-) > > diff --git a/src/api2/types/mod.rs b/src/api2/types/mod.rs > index e829f207..21b5eade 100644 > --- a/src/api2/types/mod.rs > +++ b/src/api2/types/mod.rs > @@ -114,6 +114,8 @@ const_regex!{ > pub UUID_REGEX = r"^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$"; > > pub DATASTORE_MAP_REGEX = concat!(r"(:?", PROXMOX_SAFE_ID_REGEX_STR!(), r"=)?", PROXMOX_SAFE_ID_REGEX_STR!()); > + > + pub TAPE_RESTORE_SNAPSHOT_REGEX = concat!(r"^", PROXMOX_SAFE_ID_REGEX_STR!(), r":", SNAPSHOT_PATH_REGEX_STR!(), r"$"); > } > > pub const SYSTEMD_DATETIME_FORMAT: ApiStringFormat = > @@ -185,6 +187,9 @@ pub const BLOCKDEVICE_NAME_FORMAT: ApiStringFormat = > pub const DATASTORE_MAP_FORMAT: ApiStringFormat = > ApiStringFormat::Pattern(&DATASTORE_MAP_REGEX); > > +pub const TAPE_RESTORE_SNAPSHOT_FORMAT: ApiStringFormat = > + ApiStringFormat::Pattern(&TAPE_RESTORE_SNAPSHOT_REGEX); > + > pub const PASSWORD_SCHEMA: Schema = StringSchema::new("Password.") > .format(&PASSWORD_FORMAT) > .min_length(1) > @@ -396,6 +401,12 @@ pub const DATASTORE_MAP_LIST_SCHEMA: Schema = StringSchema::new( > .format(&ApiStringFormat::PropertyString(&DATASTORE_MAP_ARRAY_SCHEMA)) > .schema(); > > +pub const TAPE_RESTORE_SNAPSHOT_SCHEMA: Schema = StringSchema::new( > + "A snapshot in the format: 'store:type/id/time") > + .format(&TAPE_RESTORE_SNAPSHOT_FORMAT) > + .type_text("store:type/id/time") > + .schema(); > + > pub const MEDIA_SET_UUID_SCHEMA: Schema = > StringSchema::new("MediaSet Uuid (We use the all-zero Uuid to reseve an empty media for a specific pool).") > .format(&UUID_FORMAT) > diff --git a/src/backup.rs b/src/backup.rs > index cca43881..ae937be0 100644 > --- a/src/backup.rs > +++ b/src/backup.rs > @@ -238,6 +238,7 @@ pub use fixed_index::*; > mod dynamic_index; > pub use dynamic_index::*; > > +#[macro_use] > mod backup_info; > pub use backup_info::*; > > diff --git a/src/backup/backup_info.rs b/src/backup/backup_info.rs > index b0f6e31c..f39f2ed4 100644 > --- a/src/backup/backup_info.rs > +++ b/src/backup/backup_info.rs > @@ -25,6 +25,13 @@ macro_rules! BACKUP_TIME_RE { > }; > } > > +#[macro_export] > +macro_rules! SNAPSHOT_PATH_REGEX_STR { > + () => ( > + concat!(r"(", BACKUP_TYPE_RE!(), ")/(", BACKUP_ID_RE!(), ")/(", BACKUP_TIME_RE!(), r")") > + ); > +} > + > const_regex! { > BACKUP_FILE_REGEX = r"^.*\.([fd]idx|blob)$"; > > @@ -37,7 +44,7 @@ const_regex! { > GROUP_PATH_REGEX = concat!(r"^(", BACKUP_TYPE_RE!(), ")/(", BACKUP_ID_RE!(), r")$"); > > SNAPSHOT_PATH_REGEX = concat!( > - r"^(", BACKUP_TYPE_RE!(), ")/(", BACKUP_ID_RE!(), ")/(", BACKUP_TIME_RE!(), r")$"); > + r"^", SNAPSHOT_PATH_REGEX_STR!(), r"$"); > } > > /// BackupGroup is a directory containing a list of BackupDir