From: "Stefan Sterz" <s.sterz@proxmox.com>
To: "Dominik Csapak" <d.csapak@proxmox.com>, <pmg-devel@lists.proxmox.com>
Subject: Re: [pmg-devel] [PATCH pmg-api 1/2] fix #4392: keep empty user bl/wl in database
Date: Thu, 22 Feb 2024 11:56:30 +0100 [thread overview]
Message-ID: <CZBJXO3HCDPL.5P8H1Z0QTXVF@proxmox.com> (raw)
In-Reply-To: <20240215115859.1878868-1-d.csapak@proxmox.com>
On Thu Feb 15, 2024 at 12:58 PM CET, Dominik Csapak wrote:
> since our cluster sync does currently not handle vanishing rows.
> So by keeping the empty entries, they get properly synced to the
> other nodes.
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> This should be seen as a workaround for now. The "real" fix would
> probably be to use a better db schema for the user bl/wl. With that
> we have to do a db migration anyway so we can then cleanup the empty
> entries too.
>
this does seem to work as advertised. one small side-effect of keeping
empty entries is that they will still be suggested in the front-ends
combobox.
syncing worked in both direction for me.
> src/PMG/Quarantine.pm | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/src/PMG/Quarantine.pm b/src/PMG/Quarantine.pm
> index d3d0640..bd231e4 100644
> --- a/src/PMG/Quarantine.pm
> +++ b/src/PMG/Quarantine.pm
> @@ -71,16 +71,15 @@ sub add_to_blackwhite {
> }
>
> my $queries = "DELETE FROM UserPrefs WHERE pmail = $qu AND (Name = 'WL' OR Name = 'BL');";
> - if (scalar(keys %{$list->{WL}})) {
> - $queries .=
> - "INSERT INTO UserPrefs (PMail, Name, Data, MTime) " .
> - "VALUES ($qu, 'WL', $wlist, EXTRACT (EPOCH FROM now())::INTEGER);";
> - }
> - if (scalar(keys %{$list->{BL}})) {
> - $queries .=
> - "INSERT INTO UserPrefs (PMail, Name, Data, MTime) " .
> - "VALUES ($qu, 'BL', $blist, EXTRACT (EPOCH FROM now())::INTEGER);";
> - }
> +
> + $queries .=
> + "INSERT INTO UserPrefs (PMail, Name, Data, MTime) " .
> + "VALUES ($qu, 'WL', $wlist, EXTRACT (EPOCH FROM now())::INTEGER);";
> +
> + $queries .=
> + "INSERT INTO UserPrefs (PMail, Name, Data, MTime) " .
> + "VALUES ($qu, 'BL', $blist, EXTRACT (EPOCH FROM now())::INTEGER);";
> +
one small nit (that really isn't this patches fault): imo this should be
wrapped like this:
```
$queries .= "INSERT INTO UserPrefs (PMail, Name, Data, MTime) " .
"VALUES ($qu, 'WL', $wlist, EXTRACT (EPOCH FROM now())::INTEGER);";
$queries .= "INSERT INTO UserPrefs (PMail, Name, Data, MTime) " .
"VALUES ($qu, 'BL', $blist, EXTRACT (EPOCH FROM now())::INTEGER);";
```
so consider this:
Tested-by: Stefan Sterz <s.sterz@proxmox.com>
> $dbh->do($queries);
> }
>
next prev parent reply other threads:[~2024-02-22 10:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 11:58 Dominik Csapak
2024-02-15 11:58 ` [pmg-devel] [RFC PATCH pmg-api 2/2] api: proxy user bl/wl calls to master Dominik Csapak
2024-02-22 10:57 ` Stefan Sterz
2024-02-22 14:53 ` Stoiko Ivanov
2024-02-22 15:00 ` Stoiko Ivanov
2024-02-22 10:56 ` Stefan Sterz [this message]
2024-02-22 14:44 ` [pmg-devel] applied: [PATCH pmg-api 1/2] fix #4392: keep empty user bl/wl in database 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=CZBJXO3HCDPL.5P8H1Z0QTXVF@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=d.csapak@proxmox.com \
--cc=pmg-devel@lists.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.