[PATCH 2/2] testbot/Janitor: Clean up the latest directory too.

Francois Gouget fgouget at codeweavers.com
Tue Jun 26 04:03:41 CDT 2018


Signed-off-by: Francois Gouget <fgouget at 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)
 {
-- 
2.18.0



More information about the wine-devel mailing list