public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lorenz Stechauner <l.stechauner@proxmox.com>
To: Wolfgang Bumiller <w.bumiller@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH v2 storage] storage/plugin: factoring out regex for backup extension rey
Date: Wed, 4 Aug 2021 09:56:14 +0200	[thread overview]
Message-ID: <094809ab-989e-4256-cada-184253fca9ad@proxmox.com> (raw)
In-Reply-To: <20210803071526.4njczxtwwtvry5zj@olga.proxmox.com>


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 <l.stechauner@proxmox.com>
>> ---
>> 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.




  reply	other threads:[~2021-08-04  7:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 10:52 [pve-devel] [PATCH v2 storage] storage/plugin: factoring out regex for backup extension re Lorenz Stechauner
2021-08-03  7:15 ` [pve-devel] [PATCH v2 storage] storage/plugin: factoring out regex for backup extension rey Wolfgang Bumiller
2021-08-04  7:56   ` Lorenz Stechauner [this message]
2021-08-04  8:21     ` Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=094809ab-989e-4256-cada-184253fca9ad@proxmox.com \
    --to=l.stechauner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=w.bumiller@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal