Module: tools Branch: master Commit: ff79ab5a21866c01c67badda8e8f5957f7a6d065 URL: https://source.winehq.org/git/tools.git/?a=commit;h=ff79ab5a21866c01c67badda...
Author: Francois Gouget fgouget@codeweavers.com Date: Tue Jun 26 11:03:28 2018 +0200
testbot/Janitor: Add DeletePath() to simplify deleting file/directories.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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 9fb38ef..9252efa 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); } } }