public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api] utils: always load custom SpamAssassin descriptions
Date: Thu, 30 Jun 2022 15:44:21 +0200	[thread overview]
Message-ID: <20220630134421.24476-1-s.ivanov@proxmox.com> (raw)

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





                 reply	other threads:[~2022-06-30 13:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220630134421.24476-1-s.ivanov@proxmox.com \
    --to=s.ivanov@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 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