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 D217E6B173 for ; Tue, 3 Aug 2021 09:16:02 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B577DF099 for ; Tue, 3 Aug 2021 09:15:32 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 363EEF08D for ; Tue, 3 Aug 2021 09:15:32 +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 E842242CF7 for ; Tue, 3 Aug 2021 09:15:26 +0200 (CEST) Date: Tue, 3 Aug 2021 09:15:26 +0200 From: Wolfgang Bumiller To: Lorenz Stechauner Cc: pve-devel@lists.proxmox.com Message-ID: <20210803071526.4njczxtwwtvry5zj@olga.proxmox.com> References: <20210802105236.698205-1-l.stechauner@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210802105236.698205-1-l.stechauner@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.657 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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. [storage.pm, plugin.pm] Subject: Re: [pve-devel] [PATCH v2 storage] storage/plugin: factoring out regex for backup extension rey X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Aug 2021 07:16:02 -0000 On Mon, Aug 02, 2021 at 12:52:36PM +0200, Lorenz Stechauner wrote: > Signed-off-by: Lorenz Stechauner > --- > changes to v1: > * factored $compressor_extension_re out of $backup_extension_re > should now be less confusing not sure about less confusing... but I suppose it'll have to do > > PVE/Storage.pm | 14 +++++++++----- > PVE/Storage/Plugin.pm | 4 ++-- > 2 files changed, 11 insertions(+), 7 deletions(-) > > diff --git a/PVE/Storage.pm b/PVE/Storage.pm > index c04b5a2..942246f 100755 > --- a/PVE/Storage.pm > +++ b/PVE/Storage.pm > @@ -105,6 +105,10 @@ our $iso_extension_re = qr/\.(?:iso|img)/i; > > our $vztmpl_extension_re = qr/\.tar\.([gx]z)/i; > > +our $compressor_extension_re = qr/\.(${\PVE::Storage::Plugin::COMPRESSOR_RE})/i; > + > +our $backup_extension_re = qr/\.(tgz|(?:tar|vma)$compressor_extension_re?)/i; The reason I don't find it less confusing is that both of these are globals, and one introduces 1 capture group, the other introduces 2 capture groups. I'd say "let's just use named capture groups everywhere", but then if we ever add branch reset patterns (`(?|a|b|c)`) it all falls apart... I think we should probably add doc comments at least... also maybe introduce a naming scheme? $COMPRESSOR_EXTENSION_RE_1 $BACKUP_EXTENSION_AND_COMPRESSION_RE_2 or something? Not sure the numbering is a good idea, but at least naming one "X_AND_Y" shows there are 2 things involved, and might hint future editors that adding more groups should also update the name.