From 473a272066d2448c3e4617a6c2ff8b496be47078 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Tue, 4 Oct 2016 23:59:58 +0200 Subject: [PATCH] Assume file has vanished if we can't lstat it A file might be deleted between the time we read the directory and the time we get around to check it, so if we can't lstat it, assume that is what has happened. (It might also have been renamed, but that's equivalent to this file being deleted and another being created, so we don't have to treat this specially) --- cleandir/cleandir.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cleandir/cleandir.pl b/cleandir/cleandir.pl index a6279eb..26b371b 100755 --- a/cleandir/cleandir.pl +++ b/cleandir/cleandir.pl @@ -97,6 +97,10 @@ sub cleandir { print STDERR "$0:", " " x $level, " checking $dir/$i\n"; } my $st = lstat("$i"); + if (!defined($st)) { + # file has vanished + next; + } my $action = 'i'; # Skip anything on a different filesystem