From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Stoiko Ivanov <s.ivanov@proxmox.com>
Cc: pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api v2 2/4] api: spamassassin: read local channels
Date: Tue, 19 Jan 2021 10:10:08 +0100 [thread overview]
Message-ID: <d6191783-5806-5e70-9643-3ca82cdc072b@proxmox.com> (raw)
In-Reply-To: <20210118204756.2ac6db0e@rosa.proxmox.com>
On 18.01.21 20:47, Stoiko Ivanov wrote:
>>> + my $check_channel = sub {
>>> + my ($channel) = @_;
>>> +
>>> + # see sa-update source:
>>> + my $channel_file_base = $channel;
>>> + $channel_file_base =~ s/[^A-Za-z0-9-]+/_/g;
>>> + my $channelfile = "${sa_update_dir}${channel_file_base}.cf";
>>> +
>>> + my $mtime = -1;
>>> + my $version = -1;
> $version gets initialized to -1 here...
>>> + my $newversion = -1;
>>> +
>>> + if (-f $channelfile) {
>>> + # stat metadata cf file
>>> + $mtime = (stat($channelfile))[9]; # 9 is mtime
>>> +
>>> + # parse version from metadata cf file
>>> + my $metadata = PVE::Tools::file_read_firstline($channelfile);
>>> + if ($metadata =~ m/\s([0-9]+)$/) {
>>> + $version = $1;
>>> + } else {
>>> + warn "invalid metadata in '$channelfile'\n";
>> I know it was already there, but this mayresults in a undef comparison
>> when checking `if ($newversion > $version) {` below.
>> I'd do a separate followup with that being fixed, e.g., by either prepending the
>> if check with a `!defined($version) || ...` check or setting it to -1000 or so.
> so it should not be undefined if the metadata is not matching?
> (I quickly tested in on my system - and if I drop the -1 I get a undef
> comparison in the logs - but it works as is)
> or am I missing something?
>
Ok, my bad then - sorry!
next prev parent reply other threads:[~2021-01-19 9:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-30 17:15 [pmg-devel] [PATCH pmg-api v2 0/4] add support for locally configured SA channels Stoiko Ivanov
2020-12-30 17:15 ` [pmg-devel] [PATCH pmg-api v2 1/4] add helper for parsing SA channel.d files Stoiko Ivanov
2021-01-15 8:21 ` Thomas Lamprecht
2020-12-30 17:15 ` [pmg-devel] [PATCH pmg-api v2 2/4] api: spamassassin: read local channels Stoiko Ivanov
2021-01-15 10:02 ` Thomas Lamprecht
2021-01-18 19:47 ` Stoiko Ivanov
2021-01-19 9:10 ` Thomas Lamprecht [this message]
2020-12-30 17:15 ` [pmg-devel] [PATCH pmg-api v2 3/4] api: spamassassin: update " Stoiko Ivanov
2021-01-15 9:58 ` Thomas Lamprecht
2020-12-30 17:15 ` [pmg-devel] [PATCH pmg-api v2 4/4] pmg-daily: run sa-update for " Stoiko Ivanov
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=d6191783-5806-5e70-9643-3ca82cdc072b@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
--cc=s.ivanov@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal