From: Stefan Schantl <stefan.schantl@ipfire.org>
To: development@lists.ipfire.org
Cc: Stefan Schantl <stefan.schantl@ipfire.org>
Subject: [PATCH 1/2] urlfiler: Cleanup list directory during update
Date: Sun, 22 Feb 2026 20:07:52 +0100 [thread overview]
Message-ID: <20260222190753.10632-1-stefan.schantl@ipfire.org> (raw)
Cleanup the directory which contains the downloaded blocklists during
the update process. As the same code is used for sheduled and manual
updates/list installs this also cleans up old lists when switching the
lists provider.
Fixes #13820.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
config/urlfilter/autoupdate.pl | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/config/urlfilter/autoupdate.pl b/config/urlfilter/autoupdate.pl
index 39b9b4f0b..05db6e339 100644
--- a/config/urlfilter/autoupdate.pl
+++ b/config/urlfilter/autoupdate.pl
@@ -7,6 +7,7 @@
# $Id: autoupdate.pl,v 1.1 2007/03/14 00:00:00 marco.s Exp $
#
use strict;
+use File::Path;
require "/var/ipfire/general-functions.pl";
@@ -115,6 +116,7 @@ unless ($blacklist_url eq '')
system("/usr/bin/squidGuard -d -c $target/update.conf -C all");
+ &cleanupdbdir();
system("cp -r $target/blacklists/* $dbdir");
system("chown -R nobody.nobody $dbdir");
@@ -214,3 +216,27 @@ sub setpermissions
}
# -------------------------------------------------------------------
+
+sub cleanupdbdir {
+ # Open the database directory and do a directory listing.
+ opendir(DIR, "$dbdir") or die "Cannot open $dbdir. $!\n";
+
+ # Loop through the directory.
+ while (my $item = readdir(DIR)) {
+ # Skip . and ..
+ next if ($item eq ".");
+ next if ($item eq "..");
+
+ # Generate absolute path.
+ my $abs_path = "$dbdir/$item";
+
+ # Skip anything which is not a directory.
+ next unless (-d "$abs_path");
+
+ # Remove the directory and the content.
+ &File::Path::remove_tree($abs_path);
+ }
+
+ # Close directory handle.
+ closedir(DIR);
+}
--
2.47.3
next reply other threads:[~2026-02-22 19:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-22 19:07 Stefan Schantl [this message]
2026-02-22 19:07 ` [PATCH 2/2] urlfilter: Fix syntax when calling chown Stefan Schantl
2026-02-23 11:34 ` [PATCH 1/2] urlfiler: Cleanup list directory during update Michael Tremer
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=20260222190753.10632-1-stefan.schantl@ipfire.org \
--to=stefan.schantl@ipfire.org \
--cc=development@lists.ipfire.org \
/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