scan: never record its own database files (closes #115) #128

Merged
clawbot merged 1 commits from issue-115-database-files into next 2026-10-17 04:10:51 +02:00
Collaborator

Fixes #115.

When the database lay under a scanned operand, the walk recorded the database file, its -wal and -shm files and its .lock file like any other file: every rescan updated them, and report paired them with the tree's empty files.

What changed:

  • databaseFiles in db.go notes the device and inode of those four files, named from the database's path with symlinks resolved, as SQLite and the lock already name them. runScan calls it once the database and the lock file are open, when all four exist.
  • In scan.go, emitFile (a file below an operand) and seedRoot (a regular-file operand) pass over a file with one of those identities: no event, so no line, no count and no record. A record an earlier scan left for one of them is deleted as unverified.
  • README "Rules for the walk" states the rule; the smoke-test note on keeping the database out of the tree is gone.

What the diff does not show:

  • Matching is by device and inode, not path, so an operand reached through a symlinked directory still matches.
  • No -journal file is noted: the database is in WAL mode for the whole walk.
  • The -wal and -shm files keep their inode through the walk, because the scan's one connection stays open and nothing is written before the hash phase.

Judgement call: walkRules, in exclude.go, carries the noted files to the walk, since it already reaches every walk function.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/sfdupes/issues/115. When the database lay under a scanned operand, the walk recorded the database file, its `-wal` and `-shm` files and its `.lock` file like any other file: every rescan updated them, and `report` paired them with the tree's empty files. What changed: - `databaseFiles` in `db.go` notes the device and inode of those four files, named from the database's path with symlinks resolved, as SQLite and the lock already name them. `runScan` calls it once the database and the lock file are open, when all four exist. - In `scan.go`, `emitFile` (a file below an operand) and `seedRoot` (a regular-file operand) pass over a file with one of those identities: no event, so no line, no count and no record. A record an earlier scan left for one of them is deleted as unverified. - README "Rules for the walk" states the rule; the smoke-test note on keeping the database out of the tree is gone. What the diff does not show: - Matching is by device and inode, not path, so an operand reached through a symlinked directory still matches. - No `-journal` file is noted: the database is in WAL mode for the whole walk. - The `-wal` and `-shm` files keep their inode through the walk, because the scan's one connection stays open and nothing is written before the hash phase. Judgement call: `walkRules`, in `exclude.go`, carries the noted files to the walk, since it already reaches every walk function. Model: opus-5-5
clawbot added 1 commit 2026-10-17 03:56:44 +02:00
When the database lay under a scanned operand, the walk recorded the
database file, its -wal and -shm files and its .lock file like any other
file, so every rescan updated them and report paired them with empty
files. Once the database and the lock file are open, the scan now notes
their device and inode, and the walk passes over a file with one of
them, as an operand or below one, printing no line and counting
nothing. Matching by device and inode holds through a symlinked
directory, where comparing paths would not. A record an earlier scan
left for one of them is deleted as unverified. README's smoke-test note
on keeping the database out of the tree is gone, as it no longer holds.

Judgement call: walkRules, in exclude.go, carries the noted files to the walk.

Model: opus-5-5
clawbot added the needs-review label 2026-10-17 03:56:48 +02:00
clawbot self-assigned this 2026-10-17 03:56:49 +02:00
Author
Collaborator

Review passed: #128 meets the definition of done of #115.

Model: opus-5-5

Review passed: https://git.eeqj.de/sneak/sfdupes/pulls/128 meets the definition of done of https://git.eeqj.de/sneak/sfdupes/issues/115. Model: opus-5-5
clawbot merged commit dcfe0ea080 into next 2026-10-17 04:10:51 +02:00
clawbot deleted branch issue-115-database-files 2026-10-17 04:10:51 +02:00
Sign in to join this conversation.