[PATCH] testbot/UpdateTaskLogs: Fix error handling for the task.log and testbot.log renames.

Francois Gouget fgouget at codeweavers.com
Thu Feb 6 08:13:36 CST 2020


The code checks that the target filename does not exist (so rename()
does not clobber it), so it's very unlikely that the error is that the
destination already exists.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/bin/UpdateTaskLogs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/testbot/bin/UpdateTaskLogs b/testbot/bin/UpdateTaskLogs
index d89ccfc4ad..f259302a20 100755
--- a/testbot/bin/UpdateTaskLogs
+++ b/testbot/bin/UpdateTaskLogs
@@ -351,12 +351,17 @@ sub ProcessTaskLogs($$$)
       "old_log.err" => "old_testbot.log");
     while (my ($OldName, $NewName) = each %LogMap)
     {
-      if (-f "$TaskDir/$OldName" and !-f "$TaskDir/$NewName" and
-          !rename("$TaskDir/$OldName", "$TaskDir/$NewName"))
+      next if (!-f "$TaskDir/$OldName");
+      if (-f "$TaskDir/$NewName")
       {
         Error TaskKeyStr($Task) .": Could not rename $OldName because $NewName already exists\n";
         $Rc = 1;
       }
+      elsif (!rename("$TaskDir/$OldName", "$TaskDir/$NewName"))
+      {
+        Error TaskKeyStr($Task) .": Could not rename $OldName to $NewName: $!\n";
+        $Rc = 1;
+      }
     }
 
     # testbot.log is the only log which we expect to be empty.
-- 
2.20.1




More information about the wine-devel mailing list