[pmg-devel] [PATCH pmg-api] utils: always load custom SpamAssassin descriptions

Stoiko Ivanov s.ivanov at proxmox.com
Thu Jun 30 15:44:21 CEST 2022


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 at 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





More information about the pmg-devel mailing list