Skip to content

Commit

Permalink
cron/rm_stale_links: tweak indenting
Browse files Browse the repository at this point in the history
previously, there was an odd number of spaces for the bulk of the `find`
sub, which was sort of a pain to deal with
  • Loading branch information
rjbs committed May 4, 2024
1 parent 16c8188 commit cb633fb
Showing 1 changed file with 35 additions and 34 deletions.
69 changes: 35 additions & 34 deletions cron/rm_stale_links
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,40 @@ my %KEEP_FOREVER = (
);

find(
{
bydepth => 1,
wanted => sub {
return if /^\.\.?$/;
return if $KEEP_FOREVER{ $File::Find::name };
my($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_);
if (-l $_ && ! -e $_){
$Logger->log("unlinking stale $File::Find::name");
unlink $_;
# PAUSE::delfile_hook(File::Spec->rel2abs($_)); # do we track symlinks?
{
bydepth => 1,
wanted => sub {
return if /^\.\.?$/;
return if $KEEP_FOREVER{ $File::Find::name };
my($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_);
if (-l $_ && ! -e $_){
$Logger->log("unlinking stale $File::Find::name");
unlink $_;
# PAUSE::delfile_hook(File::Spec->rel2abs($_)); # do we track symlinks?
}
if ($_ eq "CHECKSUMS") {
opendir DIR, ".";
my @readdir = readdir DIR;
closedir DIR;
if (@readdir == 3) {
$Logger->log("unlinking orphaned $File::Find::name");
unlink $_ or die "Could not unlink $_: $!";
PAUSE::delfile_hook(File::Spec->rel2abs($_)); # definitely needed
}
if ($_ eq "CHECKSUMS") {
opendir DIR, ".";
my @readdir = readdir DIR;
closedir DIR;
if (@readdir == 3) {
$Logger->log("unlinking orphaned $File::Find::name");
unlink $_ or die "Could not unlink $_: $!";
PAUSE::delfile_hook(File::Spec->rel2abs($_)); # definitely needed
}
}
return if -l $_;
($dev,$ino,$mode,$nlink,$uid,$gid) = stat($_);
if (-d _ and $nlink == 2) { # directory without subdir
opendir DIR, $_;
my @readdir = readdir DIR;
closedir DIR;
if (@readdir == 2) {
$Logger->log("rmdirring empty $File::Find::name");
rmdir $_ or die "Could not rmdir $_: $!";
# PAUSE::delfile_hook(File::Spec->rel2abs($_)); # we do not track directories
}
return if -l $_;
($dev,$ino,$mode,$nlink,$uid,$gid) = stat($_);
if (-d _ and $nlink == 2) { # directory without subdir
opendir DIR, $_;
my @readdir = readdir DIR;
closedir DIR;
if (@readdir == 2) {
$Logger->log("rmdirring empty $File::Find::name");
rmdir $_ or die "Could not rmdir $_: $!";
# PAUSE::delfile_hook(File::Spec->rel2abs($_)); # we do not track directories
}
}
},
},
"authors", "modules");
}
},
},
"authors", "modules"
);

0 comments on commit cb633fb

Please sign in to comment.