dupemerge: merge with waya-zblaxell, fix warning message
[dupemerge] / faster-dupemerge
index 4ad0176ea3dfcddddc95fa685aa8c2c9ef63d0f6..be6e29bc678bd78aec0d92fef00f030e8d829ef3 100755 (executable)
@@ -288,6 +288,13 @@ sub link_files {
        }
 }
 
+# Convert $dev,$ino into a single string where lexical and numeric orderings are equivalent
+sub format_inode ($$) {
+       my ($dev, $ino) = @_;
+       # 64 bits ought to be enough for everybody!
+       return sprintf('%016x:%016x', $dev, $ino);
+}
+
 # Process all known files so far.
 sub merge_files {
        $merges_attempted++;
@@ -360,8 +367,8 @@ incumbent_file:
                                                        next incumbent_file;
                                                }
 
-                                               if ($incumbent_ino != $incumbent) {
-                                                       warn "$incumbent_file: expected inode $incumbent, found $incumbent_ino";
+                                               if (format_inode($incumbent_dev, $incumbent_ino) ne $incumbent) {
+                                                       warn "$incumbent_file: expected inode $incumbent, found $incumbent_dev:$incumbent_ino";
                                                        $surprises++;
                                                        next incumbent_file;
                                                }
@@ -380,8 +387,8 @@ candidate_file:
                                                                next candidate_file;
                                                        }
 
-                                                       if ($candidate_ino != $candidate) {
-                                                               warn "$candidate_file: expected inode $candidate, found $candidate_ino";
+                                                       if (format_inode($candidate_dev, $candidate_ino) ne $candidate) {
+                                                               warn "$candidate_file: expected inode $candidate, found $candidate_dev:$candidate_ino";
                                                                $surprises++;
                                                                next candidate_file;
                                                        }
@@ -546,8 +553,7 @@ while (<FIND>) {
        my ($weak_key, $dev, $ino, $name) = m/^(\d+ \d+ \d+ \d+ -?[\d.]+) (\d+) (\d+) (.+)\0$/so;
        die "read error: $!\nLast input line was '$_'" unless defined($name);
 
-       # 64 bits out to be enough for everybody!
-       my $inode = sprintf('%016x:%016x', $dev, $ino);
+       my $inode = format_inode($dev, $ino);
 
        print STDERR "weak_key=$weak_key inode=$inode name=$name\n" if $debug;