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 25DEB6B67D for ; Wed, 4 Aug 2021 10:21:06 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1AD891C4A1 for ; Wed, 4 Aug 2021 10:21:06 +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 980F51C496 for ; Wed, 4 Aug 2021 10:21:05 +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 662E642DA0 for ; Wed, 4 Aug 2021 10:21:05 +0200 (CEST) Date: Wed, 4 Aug 2021 10:21:04 +0200 From: Wolfgang Bumiller To: Lorenz Stechauner Cc: pve-devel@lists.proxmox.com Message-ID: <20210804082104.cck5srpoinlqg34d@wobu-vie.proxmox.com> References: <20210802105236.698205-1-l.stechauner@proxmox.com> <20210803071526.4njczxtwwtvry5zj@olga.proxmox.com> <094809ab-989e-4256-cada-184253fca9ad@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <094809ab-989e-4256-cada-184253fca9ad@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.653 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: Wed, 04 Aug 2021 08:21:06 -0000 On Wed, Aug 04, 2021 at 09:56:14AM +0200, Lorenz Stechauner wrote: > > On 03.08.21 09:15, Wolfgang Bumiller wrote: > > 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. > how about using on all three regex'es (iso, vztmpl, backup) two capture > groups? > it would be a bit less confusing, because it's more consistent (?) > > ".tar.gz" -> $1 = "tar.gz"; $2 = "gz" > ".iso" -> $1 = "iso"; $2 = "" > > would something like this be a good (or at least better) idea? > > our $ISO_EXT_RE = qr/\.(iso|img)()/i; Part of me is making a 🤪 face here... > our $VZTMPL_EXT_RE = qr/\.(tar\.([gx]z))/i; > our $BACKUP_EXT_RE = > qr/\.(tgz|(?:tar|vma)(?:\.(${\PVE::Storage::Plugin::COMPRESSOR_RE}))?)/i; BUt also, part of me *does* like this more (though maybe with `((iso|img))` to have `$2 eq $1` on the ISO one... but I'm not sure there'll ever be a "perfect" version anyway... I guess doc comments to point out the differences are more important than the actual REs... Your choice.