aboutsummaryrefslogtreecommitdiff
path: root/internal/dup/dup_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/dup/dup_test.go')
-rw-r--r--internal/dup/dup_test.go45
1 files changed, 22 insertions, 23 deletions
diff --git a/internal/dup/dup_test.go b/internal/dup/dup_test.go
index ed7c1a3..bd593de 100644
--- a/internal/dup/dup_test.go
+++ b/internal/dup/dup_test.go
@@ -368,13 +368,12 @@ func linked(t *testing.T, dir, name string, target scan.File) scan.File {
return scan.File{Path: p, Rel: name, Name: name, Size: fi.Size(), ModTime: fi.ModTime()}
}
-// TestHardlinksAreNotDuplicatesOfEachOther is R10 (plan 5 Task 2, added to
-// the task outside the brief): spec §5.5 groups duplicate candidates by size
-// and hash, with no inode check, so two hardlinked names - one inode, byte-
-// identical by construction - were judged a duplicate pair. A rule of
-// (when (duplicate)) (delete) would then remove a name the user relies on
-// even though nothing was ever actually copied. os.SameFile must stop a
-// file being judged a duplicate of itself under another name.
+// TestHardlinksAreNotDuplicatesOfEachOther: spec §5.5 groups duplicate
+// candidates by size and hash, with no inode check, so two hardlinked names
+// - one inode, byte-identical by construction - were judged a duplicate
+// pair. A rule of (when (duplicate)) (delete) would then remove a name the
+// user relies on even though nothing was ever actually copied. os.SameFile
+// must stop a file being judged a duplicate of itself under another name.
func TestHardlinksAreNotDuplicatesOfEachOther(t *testing.T) {
d := t.TempDir()
a := put(t, d, "a.pdf", []byte("same content"), 0)
@@ -392,13 +391,13 @@ func TestHardlinksAreNotDuplicatesOfEachOther(t *testing.T) {
}
}
-// TestHardlinksAreStillDuplicatesOfASeparateIdenticalFile is R10's other
-// direction, and the one a naive "same size+hash means never a duplicate"
-// fix would get wrong: a.pdf and b.pdf are hardlinks of one inode, but
-// c.pdf is a genuinely separate, byte-identical copy under an extra
-// (duplicate "DIR") directory, so spec §5.5 prefers it as the original.
-// Deleting a.pdf and b.pdf then leaves the content intact in c.pdf - they
-// really are duplicates, of c.pdf, and must still be reported as such.
+// TestHardlinksAreStillDuplicatesOfASeparateIdenticalFile is the direction
+// a naive "same size+hash means never a duplicate" fix would get wrong:
+// a.pdf and b.pdf are hardlinks of one inode, but c.pdf is a genuinely
+// separate, byte-identical copy under an extra (duplicate "DIR") directory,
+// so spec §5.5 prefers it as the original. Deleting a.pdf and b.pdf then
+// leaves the content intact in c.pdf - they really are duplicates, of
+// c.pdf, and must still be reported as such.
func TestHardlinksAreStillDuplicatesOfASeparateIdenticalFile(t *testing.T) {
scanned, filed := t.TempDir(), t.TempDir()
a := put(t, scanned, "a.pdf", []byte("same content"), 0)
@@ -418,15 +417,15 @@ func TestHardlinksAreStillDuplicatesOfASeparateIdenticalFile(t *testing.T) {
}
}
-// TestHardlinkUnderExtraDirWithNoOtherCopyIsNotADuplicate is R10 extended
-// to extra-directory candidates: a candidate is never a duplicate of a
-// candidate that is the same file, and extra-directory candidates are
-// candidates - the rule is not scanned-vs-scanned only. This is the shape
-// (duplicate "DIR") exists for: (duplicate "~/backup") means "the backup
-// already holds a copy, so the local name can go", but if ~/backup/a.pdf is
-// a hardlink of ~/dl/a.pdf, the backup holds no copy at all, just the same
-// file under a second name - judging the scanned file a duplicate would
-// delete the only copy while the user believes it is backed up.
+// TestHardlinkUnderExtraDirWithNoOtherCopyIsNotADuplicate: a candidate is
+// never a duplicate of a candidate that is the same file, and extra-
+// directory candidates are candidates - the rule is not scanned-vs-scanned
+// only. This is the shape (duplicate "DIR") exists for: (duplicate
+// "~/backup") means "the backup already holds a copy, so the local name can
+// go", but if ~/backup/a.pdf is a hardlink of ~/dl/a.pdf, the backup holds
+// no copy at all, just the same file under a second name - judging the
+// scanned file a duplicate would delete the only copy while the user
+// believes it is backed up.
//
// Lookup's os.SameFile check compares the elected original with the file
// asked about whether the original was scanned or found under an extra