Skip to content

Commit 96a90ff

Browse files
Open MPI Teamjsquyres
authored andcommitted
remove-old.pl: update / fix minor bugs
- Ensure that $to_delete is always defined - Re-indent to 4 spaces for readability - Don't only delete files -- it's ok to delete directories, too - Print the directory from which we are deleting Signed-off-by: Jeff Squyres <[email protected]>
1 parent e642d1d commit 96a90ff

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

contrib/build-server/remove-old.pl

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env perl
22

33
use strict;
4+
use warnings;
5+
46
use POSIX qw(strftime);
57

68
my $happy = 1;
@@ -22,22 +24,27 @@
2224

2325
# How many days to keep?
2426
my $t = time() - ($savedays * 60 * 60 * 24);
25-
print "Deleting anything before: " . strftime("%D", localtime($t)) . "\n";
26-
my $to_delete;
27+
print "Deleting anything in $dir before: " . strftime("%D", localtime($t)) . "\n";
28+
my $to_delete = "";
2729

2830
# Check everything in the dir; if is a dir, is not . or .., and is
2931
# older than the save date, keep it for deleting later.
30-
foreach my $file (@files) {
31-
if (-f "$dir/$file" && $file ne "index.php" && $file ne "md5sums.txt" && $file ne "sha1sums.txt" && $file ne "latest_snapshot.txt" && $file ne "." && $file ne "..") {
32-
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
33-
$atime,$mtime,$ctime,$blksize,$blocks) = stat("$dir/$file");
34-
my $str = "SAVE";
35-
if ($mtime < $t) {
36-
$to_delete = "$to_delete $dir/$file";
37-
$str = "DELETE";
32+
foreach my $file (sort(@files)) {
33+
if ($file ne "index.php" &&
34+
$file ne "md5sums.txt" &&
35+
$file ne "sha1sums.txt" &&
36+
$file ne "latest_snapshot.txt" &&
37+
$file ne "." &&
38+
$file ne "..") {
39+
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
40+
$atime,$mtime,$ctime,$blksize,$blocks) = stat("$dir/$file");
41+
my $str = "SAVE";
42+
if ($mtime < $t) {
43+
$to_delete = "$to_delete $dir/$file";
44+
$str = "DELETE";
45+
}
46+
print "Found $file: $str (mtime: " . strftime("%D", localtime($mtime)) . ")\n";
3847
}
39-
print "Found dir ($str): $file (mtime: " . strftime("%D", localtime($mtime)) . ")\n";
40-
}
4148
}
4249

4350
# If we found anything to delete, do so.

0 commit comments

Comments
 (0)