public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-api] utils: always load custom SpamAssassin descriptions
@ 2022-06-30 13:44 Stoiko Ivanov
  0 siblings, 0 replies; only message in thread
From: Stoiko Ivanov @ 2022-06-30 13:44 UTC (permalink / raw)
  To: pmg-devel

currently PMG::API2::Quarantine::decode_spaminfo is the only place
where we call PMG::Utils::load_sa_descriptions.

Should this ever change it still would make little sense to not read
all available descriptions in the potential future callsite.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---

small refactoring following the last patch from Dominik, since I had a
testsetup ready

 src/PMG/API2/Quarantine.pm | 7 +------
 src/PMG/Utils.pm           | 9 +++++++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm
index 59eb1af..592cad7 100644
--- a/src/PMG/API2/Quarantine.pm
+++ b/src/PMG/API2/Quarantine.pm
@@ -68,12 +68,7 @@ sub decode_spaminfo {
     my $res = [];
     return $res if !defined($info);
 
-    my $saversion = Mail::SpamAssassin->VERSION;
-
-    my $salocaldir = "/var/lib/spamassassin/$saversion/updates_spamassassin_org";
-    my $sacustomdir = "/etc/mail/spamassassin";
-
-    $spamdesc = PMG::Utils::load_sa_descriptions([$salocaldir, $sacustomdir]) if !$spamdesc;
+    $spamdesc = PMG::Utils::load_sa_descriptions() if !$spamdesc;
 
     foreach my $test (split (',', $info)) {
 	my ($name, $score) = split (':', $test);
diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm
index cef232b..8d389c2 100644
--- a/src/PMG/Utils.pm
+++ b/src/PMG/Utils.pm
@@ -11,6 +11,7 @@ use File::stat;
 use POSIX qw(strftime);
 use File::stat;
 use File::Basename;
+use Mail::SpamAssassin;
 use MIME::Entity;
 use MIME::Words;
 use MIME::Parser;
@@ -1166,10 +1167,14 @@ sub bencode_header {
 sub load_sa_descriptions {
     my ($additional_dirs) = @_;
 
+    my $saversion = Mail::SpamAssassin->VERSION;
+
     my @dirs = ('/usr/share/spamassassin',
-		'/usr/share/spamassassin-extra');
+		'/usr/share/spamassassin-extra',
+		"/var/lib/spamassassin/$saversion/updates_spamassassin_org",
+		'/etc/mail/spamassassin');
 
-    push @dirs, @$additional_dirs if @$additional_dirs;
+    push @dirs, @$additional_dirs if $additional_dirs;
 
     my $res = {};
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-30 13:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 13:44 [pmg-devel] [PATCH pmg-api] utils: always load custom SpamAssassin descriptions 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