Hello Stefan,

Thank you for these patches.

I added another like so that the custom lists will be kept:

  
https://git.ipfire.org/?p=ipfire-2.x.git;a=commitdiff;h=0ba18609bde216ef9ad8c485a8852e5080e32e34

All the best,
-Michael

> On 22 Feb 2026, at 19:07, Stefan Schantl <[email protected]> wrote:
> 
> 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 <[email protected]>
> ---
> 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
> 
> 


Reply via email to