From 0b5d0eb92c5be2f0ddb2fa73990f31e5654e57fe Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 15:16:55 +0200 Subject: krino: 0.0.5 — keyword cache, t and d in review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/scan/scan_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'internal/scan/scan_test.go') diff --git a/internal/scan/scan_test.go b/internal/scan/scan_test.go index a245893..e9aeb73 100644 --- a/internal/scan/scan_test.go +++ b/internal/scan/scan_test.go @@ -293,3 +293,29 @@ func TestTooBig(t *testing.T) { t.Errorf("MaxSize 0 skipped files: %v", skipped(r)) } } + +// TestFilesCarryInode: a walked file carries its device and inode, which a +// rename keeps. +func TestFilesCarryInode(t *testing.T) { + root := tree(t) + p := filepath.Join(root, "a.txt") + if err := os.WriteFile(p, []byte("x"), 0o644); err != nil { + t.Fatal(err) + } + old := now.Add(-time.Hour) + os.Chtimes(p, old, old) + first, err := Walk(root, Options{Now: now}) + if err != nil || len(first.Files) != 1 { + t.Fatalf("walk: %v %+v", err, first) + } + if first.Files[0].Ino == 0 { + t.Fatal("no inode on a unix filesystem") + } + if err := os.Rename(p, filepath.Join(root, "b.txt")); err != nil { + t.Fatal(err) + } + second, _ := Walk(root, Options{Now: now}) + if len(second.Files) != 1 || second.Files[0].Ino != first.Files[0].Ino || second.Files[0].Dev != first.Files[0].Dev { + t.Errorf("rename changed the identity: %+v then %+v", first.Files[0], second.Files) + } +} -- cgit v1.3