Also cleanup websockets

This commit is contained in:
Jamie Cameron
2024-06-03 18:42:31 -07:00
parent 2d23a3503e
commit 00ddfd4d05

View File

@ -1567,28 +1567,31 @@ if (!$gconfig{'tempdelete_days'}) {
print STDERR "Temp file clearing is disabled\n";
return;
}
# Cleanup files in /tmp/.webmin
if ($gconfig{'tempdir'} && !$gconfig{'tempdirdelete'}) {
print STDERR "Temp file clearing is not done for the custom directory $gconfig{'tempdir'}\n";
return;
}
local $tempdir = &transname();
$tempdir =~ s/\/([^\/]+)$//;
if (!$tempdir || $tempdir eq "/") {
$tempdir = "/tmp/.webmin";
}
local $cutoff = time() - $gconfig{'tempdelete_days'}*24*60*60;
opendir(DIR, $tempdir);
foreach my $f (readdir(DIR)) {
next if ($f eq "." || $f eq "..");
local @st = lstat("$tempdir/$f");
if ($st[9] < $cutoff) {
&unlink_file("$tempdir/$f");
else {
local $tempdir = &transname();
$tempdir =~ s/\/([^\/]+)$//;
if (!$tempdir || $tempdir eq "/") {
$tempdir = "/tmp/.webmin";
}
}
closedir(DIR);
local $cutoff = time() - $gconfig{'tempdelete_days'}*24*60*60;
opendir(DIR, $tempdir);
foreach my $f (readdir(DIR)) {
next if ($f eq "." || $f eq "..");
local @st = lstat("$tempdir/$f");
if ($st[9] < $cutoff) {
&unlink_file("$tempdir/$f");
}
}
closedir(DIR);
}
# Delete stale lock files
my $lockdir = $var_directory."/locks";
opendir(DIR, $lockdir);
foreach my $f (readdir(DIR)) {
@ -1600,6 +1603,12 @@ foreach my $f (readdir(DIR)) {
}
}
closedir(DIR);
# Cleanup old websockets
if (&foreign_check("xterm")) {
&foreign_require("xterm");
&xterm::cleanup_miniserv_websockets();
}
}
=head2 list_cron_files()