The files may be in a Step directory so add support for those in Path2TaskKey().
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/UpdateTaskLogs | 55 +++++++++++++++----------------------- 1 file changed, 22 insertions(+), 33 deletions(-)
diff --git a/testbot/bin/UpdateTaskLogs b/testbot/bin/UpdateTaskLogs index 93b6504422..267fdc8c0f 100755 --- a/testbot/bin/UpdateTaskLogs +++ b/testbot/bin/UpdateTaskLogs @@ -180,10 +180,25 @@ sub Path2TaskKey($)
return "latest" if (!defined $Path); return "latest" if ($Path =~ m~/latest(?:/|$)~); - $Path =~ s~^.*/jobs/(\d+/\d+/\d+)(/.*)?$~$1~; + $Path =~ s~^.*/jobs/(\d+/\d+(?:/\d+)?)(/.*)?$~$1~; return $Path; }
+sub Delete($;$) +{ + my ($Path, $Label) = @_; + + return 0 if (!-f $Path); + + my $Name = basename($Path); + $Label = defined $Label ? " $Label" : ""; + Debug(Path2TaskKey($Path) .": Deleting$Label $Name\n"); + return 0 if (unlink $Path); + + Error "Could not delete $Path: $!\n"; + return 1; +} + sub BuildErrFile($$$$) { my ($Dir, $ReportName, $IsWineTest, $TaskTimedOut) = @_; @@ -286,25 +301,10 @@ sub ProcessTaskLogs($$$) # Save this report to latest/ in case it's not already present there # (this would be the case for the oldest tasks with --rebuild) $Rc += DoUpdateLatestReport($Task, $ReportName, $RefReportPath); - - Debug(TaskKeyStr($Task) .": Deleting ../$RefReportName\n"); - } - foreach my $Suffix ("", ".err") - { - if (!unlink "$RefReportPath$Suffix" and -e "$RefReportPath$Suffix") - { - Error "Could not delete '$RefReportPath$Suffix': $!\n"; - $Rc = 1; - } - } - - next if (!-f "$TaskDir/$ReportName.err"); - Debug(TaskKeyStr($Task) .": Deleting $ReportName.err\n"); - if (!unlink "$TaskDir/$ReportName.err") - { - Error "Could not delete '$ReportName.err': $!\n"; - $Rc = 1; } + $Rc += Delete($RefReportPath); + $Rc += Delete("$RefReportPath.err"); + $Rc += Delete("$TaskDir/$ReportName.err"); } }
@@ -402,23 +402,12 @@ sub ProcessLatestReports() if ($OptDelete or $OptRebuild) { # Delete the reports that should be deleted / rebuilt - foreach my $Suffix ("", ".err") - { - next if (!-f "$LatestReportPath$Suffix"); - Debug("latest: Deleting $RefReportName$Suffix\n"); - next if (unlink "$LatestReportPath$Suffix"); - Error "Could not delete '$LatestReportPath$Suffix': $!\n"; - $Rc = 1; - } + $Rc += Delete($LatestReportPath); + $Rc += Delete("$LatestReportPath.err"); } elsif (!-f "$LatestReportPath") { - Debug("latest: Deleting orphaned $RefReportName.err\n"); - if (!unlink "$LatestReportPath.err") - { - Error "Could not delete orphaned '$LatestReportPath.err': $!\n"; - $Rc = 1; - } + $Rc += Delete("$LatestReportPath.err", "orphaned"); } elsif (!$OptDelete and !-f "$LatestReportPath.err") {