public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-api 1/2] fix #4392: keep empty user bl/wl in database
@ 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
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dominik Csapak @ 2024-02-15 11:58 UTC (permalink / raw)
  To: pmg-devel

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.

 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);";
+
 	$dbh->do($queries);
     }
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-22 15:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-15 11:58 [pmg-devel] [PATCH pmg-api 1/2] fix #4392: keep empty user bl/wl in database 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 ` [pmg-devel] [PATCH pmg-api 1/2] fix #4392: keep empty user bl/wl in database Stefan Sterz
2024-02-22 14:44 ` [pmg-devel] applied: " Stoiko Ivanov

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