Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/Janitor.pl | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/testbot/bin/Janitor.pl b/testbot/bin/Janitor.pl index 9fb38efde..9252efa65 100755 --- a/testbot/bin/Janitor.pl +++ b/testbot/bin/Janitor.pl @@ -116,6 +116,17 @@ if (defined $Usage) # Main #
+sub DeletePath($) +{ + my ($Path) = @_; + + Trace "Deleting '$Path'\n"; + if (!$DryRun and !rmtree($Path)) + { + Error "Could not delete '$Path': $!\n"; + } +} + # Delete obsolete Jobs if ($JobPurgeDays != 0) { @@ -268,11 +279,7 @@ if (opendir(my $dh, "$DataDir/staging")) { if ($Age >= $JobPurgeDays + 7) { - Trace "Deleting '$FileName'\n"; - if (!$DryRun and !rmtree($FileName)) - { - Error "Could not delete '$FileName': $!\n"; - } + DeletePath($FileName); } elsif ($Age > $JobPurgeDays) { @@ -282,12 +289,8 @@ if (opendir(my $dh, "$DataDir/staging")) } elsif ($Age >= 1) { - Trace "Deleting '$FileName'\n"; - if (!$DryRun and !unlink $FileName) - { - # The user abandoned the submit procedure half-way through - Error "Could not delete '$FileName': $!\n"; - } + # The user abandoned the submit procedure half-way through + DeletePath($FileName); } } }
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/Janitor.pl | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
diff --git a/testbot/bin/Janitor.pl b/testbot/bin/Janitor.pl index 9252efa65..a9cdd52cd 100755 --- a/testbot/bin/Janitor.pl +++ b/testbot/bin/Janitor.pl @@ -299,6 +299,52 @@ else Error "Unable to open '$DataDir/staging': $!"; }
+# Check the content of the latest directory +if (opendir(my $dh, "$DataDir/latest")) +{ + # We will be deleting files so read the directory in one go + my @Entries = readdir($dh); + close($dh); + + my $AllVMs = $VMs->Clone(); + foreach my $Entry (@Entries) + { + next if ($Entry eq "." or $Entry eq ".."); + $Entry =~ m%^([^/]+)$%; + my $FileName = "$DataDir/latest/$1"; + my $Age = int((-M $FileName) + 0.5); + + if ($Entry =~ /^(.*)_[a-z0-9]+.(?:err|log)$/) + { + # Keep the reference WineTest reports for all VMs even if they are + # retired or scheduled for deletion. + my $VMName = $1; + next if ($AllVMs->GetItem($VMName)); + } + elsif ($Entry =~ /^(?:TestLauncher[0-9]*.exe|winefiles.txt|winetest[0-9]*-latest.exe)$/) + { + next; + } + + Trace "Found a suspicious latest file: $Entry\n"; + if ($JobPurgeDays != 0) + { + if ($Age >= $JobPurgeDays + 7) + { + DeletePath($FileName); + } + elsif ($Age > $JobPurgeDays) + { + Trace "'$FileName' will be deleted in ", $JobPurgeDays + 7 - $Age, " day(s).\n"; + } + } + } +} +else +{ + Error "Unable to open '$DataDir/latest': $!"; +} + # Delete obsolete record groups if ($JobPurgeDays != 0) {