merge_files: add extra sanity check that input files are in fact files
authorZygo Blaxell <zblaxell@waya.furryterror.org>
Sat, 9 Jan 2010 02:33:20 +0000 (21:33 -0500)
committerZygo Blaxell <zblaxell@waya.furryterror.org>
Sat, 9 Jan 2010 02:33:20 +0000 (21:33 -0500)
Now that there is no '-f _' filter in the input loop, merge_files may
encounter a candidate or incumbent filename which resolves to a non-file
object on the filesystem.  If --skip-hash is not used, this sanity check
will be applied during file hashing; however, if --skip-hash is used,
the sanity check will not be applied until the files are compared.

faster-dupemerge

index 9c159eec69ac48863a4e392a258ba767822bab81..7e899ddc8eb8ae4f87770d42a33efe4acca43b95 100755 (executable)
@@ -380,7 +380,7 @@ incumbent_file:
                                                my ($incumbent_dev,$incumbent_ino,$incumbent_mode,$incumbent_nlink,$incumbent_uid,$incumbent_gid,$incumbent_rdev,$incumbent_size,$incumbent_atime,$incumbent_mtime,$incumbent_ctime,$incumbent_blksize,$incumbent_blocks) = lstat($incumbent_file);
                                                print STDERR "\t\tINCUMBENT dev=$incumbent_dev ino=$incumbent_ino mode=$incumbent_mode nlink=$incumbent_nlink uid=$incumbent_uid gid=$incumbent_gid rdev=$incumbent_rdev size=$incumbent_size atime=$incumbent_atime mtime=$incumbent_mtime ctime=$incumbent_ctime blksize=$incumbent_blksize blocks=$incumbent_blocks _=$incumbent_file\n" if $debug;
 
-                                               if (!defined($incumbent_blocks)) {
+                                               if (!defined($incumbent_blocks) || ! (-f _)) {
                                                        warn "lstat: $incumbent_file: $!";
                                                        $surprises++;
                                                        next incumbent_file;
@@ -401,7 +401,7 @@ candidate_file:
                                                        my ($candidate_dev,$candidate_ino,$candidate_mode,$candidate_nlink,$candidate_uid,$candidate_gid,$candidate_rdev,$candidate_size,$candidate_atime,$candidate_mtime,$candidate_ctime,$candidate_blksize,$candidate_blocks) = lstat($candidate_file);
                                                        print STDERR "\t\t\tCANDIDATE dev=$candidate_dev ino=$candidate_ino mode=$candidate_mode nlink=$candidate_nlink uid=$candidate_uid gid=$candidate_gid rdev=$candidate_rdev size=$candidate_size atime=$candidate_atime mtime=$candidate_mtime ctime=$candidate_ctime blksize=$candidate_blksize blocks=$candidate_blocks _=$candidate_file\n" if $debug;
 
-                                                       if (!defined($candidate_blocks)) {
+                                                       if (!defined($candidate_blocks) || ! (-f _)) {
                                                                warn "lstat: $candidate_file: $!";
                                                                $surprises++;
                                                                next candidate_file;