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 0E2406B5F2 for ; Wed, 4 Aug 2021 09:56:46 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 017421C08A for ; Wed, 4 Aug 2021 09:56:16 +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 75DB31C07C for ; Wed, 4 Aug 2021 09:56:15 +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 425A54079A for ; Wed, 4 Aug 2021 09:56:15 +0200 (CEST) To: Wolfgang Bumiller Cc: pve-devel@lists.proxmox.com References: <20210802105236.698205-1-l.stechauner@proxmox.com> <20210803071526.4njczxtwwtvry5zj@olga.proxmox.com> From: Lorenz Stechauner Message-ID: <094809ab-989e-4256-cada-184253fca9ad@proxmox.com> Date: Wed, 4 Aug 2021 09:56:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210803071526.4njczxtwwtvry5zj@olga.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.574 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 NICE_REPLY_A -0.132 Looks like a legit reply (A) 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 07:56:46 -0000 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; our $VZTMPL_EXT_RE = qr/\.(tar\.([gx]z))/i; our $BACKUP_EXT_RE = qr/\.(tgz|(?:tar|vma)(?:\.(${\PVE::Storage::Plugin::COMPRESSOR_RE}))?)/i; > > 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.