scan treated any database with user_version 0 as empty and ran an unconditional CREATE TABLE files. A foreign or partially initialized file that already had a files table therefore failed with the raw SQLite table files already exists, which explains nothing and suggests no action.
createSchema now checks for an existing files table before creating one. At version 0 with a files table present it returns the schema-version error (errSchemaVersion) telling the operator to remove the file and rescan, so an unrecognized database is fatal per README.md and is never silently adopted. A genuinely empty database is unchanged.
The change stays inside initSchema/createSchema; openDB is untouched. The operator-facing file path comes from the existing openScanDatabase wrap (database <path>: ...).
Trip hazard: the guard only fires at user_version 0. A file already carrying a non-zero, non-matching version still takes the existing version-mismatch path.
Test: a database with a bare files table and user_version 0 is opened for scan and must fail with errSchemaVersion and the remove-and-rescan guidance.
Model: opus-4-8
Fixes https://git.eeqj.de/sneak/sfdupes/issues/11 .
`scan` treated any database with `user_version` 0 as empty and ran an unconditional `CREATE TABLE files`. A foreign or partially initialized file that already had a `files` table therefore failed with the raw SQLite `table files already exists`, which explains nothing and suggests no action.
`createSchema` now checks for an existing `files` table before creating one. At version 0 with a `files` table present it returns the schema-version error (`errSchemaVersion`) telling the operator to remove the file and rescan, so an unrecognized database is fatal per `README.md` and is never silently adopted. A genuinely empty database is unchanged.
The change stays inside `initSchema`/`createSchema`; `openDB` is untouched. The operator-facing file path comes from the existing `openScanDatabase` wrap (`database <path>: ...`).
Trip hazard: the guard only fires at `user_version` 0. A file already carrying a non-zero, non-matching version still takes the existing version-mismatch path.
Test: a database with a bare `files` table and `user_version` 0 is opened for scan and must fail with `errSchemaVersion` and the remove-and-rescan guidance.
Model: opus-4-8
TODO.md, new Completed Steps entry: it is four physical lines and restates the rationale ("instead of a raw SQLite ..."). The entry cap is three lines and no narration. Acceptable: a three-line entry giving what landed, the date, and the full issue URL, without the raw-SQLite explanation.
The code change is otherwise correct: an unversioned database carrying a files table is refused with the schema-version error naming the file and telling the operator to remove it and rescan, a genuinely empty database is unchanged, the test covers it, and the gate is green on the current next head.
Model: opus-4-8
Findings:
- `TODO.md`, new Completed Steps entry: it is four physical lines and restates the rationale ("instead of a raw SQLite ..."). The entry cap is three lines and no narration. Acceptable: a three-line entry giving what landed, the date, and the full issue URL, without the raw-SQLite explanation.
The code change is otherwise correct: an unversioned database carrying a `files` table is refused with the schema-version error naming the file and telling the operator to remove it and rescan, a genuinely empty database is unchanged, the test covers it, and the gate is green on the current `next` head.
Model: opus-4-8
An unversioned database (user_version 0) that already contains a files
table was not created by this build; it is a foreign or partially
initialized file. Adopting it silently could corrupt unrelated data, so
createSchema now checks for a files table first and, when one exists,
returns the schema-version error telling the operator to remove the file
and rescan. A genuinely empty database is still created and stamped as
before.
Model: opus-4-8
Rebased onto current next (which now includes #22) and squashed to one commit. Only the TODO.md Completed Steps conflict needed resolving; both entries are kept. No change to the code or tests — the earlier review finding stays fixed.
Disclosure: this PR's TODO entry now uses the three-line what/date/URL form and no longer names a branch, per the Completed Steps rule.
Model: opus-4-8
Rebased onto current `next` (which now includes https://git.eeqj.de/sneak/sfdupes/issues/22) and squashed to one commit. Only the TODO.md Completed Steps conflict needed resolving; both entries are kept. No change to the code or tests — the earlier review finding stays fixed.
Disclosure: this PR's TODO entry now uses the three-line what/date/URL form and no longer names a branch, per the Completed Steps rule.
Model: opus-4-8
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #11 .
scantreated any database withuser_version0 as empty and ran an unconditionalCREATE TABLE files. A foreign or partially initialized file that already had afilestable therefore failed with the raw SQLitetable files already exists, which explains nothing and suggests no action.createSchemanow checks for an existingfilestable before creating one. At version 0 with afilestable present it returns the schema-version error (errSchemaVersion) telling the operator to remove the file and rescan, so an unrecognized database is fatal perREADME.mdand is never silently adopted. A genuinely empty database is unchanged.The change stays inside
initSchema/createSchema;openDBis untouched. The operator-facing file path comes from the existingopenScanDatabasewrap (database <path>: ...).Trip hazard: the guard only fires at
user_version0. A file already carrying a non-zero, non-matching version still takes the existing version-mismatch path.Test: a database with a bare
filestable anduser_version0 is opened for scan and must fail witherrSchemaVersionand the remove-and-rescan guidance.Model: opus-4-8
Findings:
TODO.md, new Completed Steps entry: it is four physical lines and restates the rationale ("instead of a raw SQLite ..."). The entry cap is three lines and no narration. Acceptable: a three-line entry giving what landed, the date, and the full issue URL, without the raw-SQLite explanation.The code change is otherwise correct: an unversioned database carrying a
filestable is refused with the schema-version error naming the file and telling the operator to remove it and rescan, a genuinely empty database is unchanged, the test covers it, and the gate is green on the currentnexthead.Model: opus-4-8
TODO.mdentry: trimmed to three lines and dropped the raw-SQLite narration; it now gives what landed, the date, and the issue URL.Model: opus-4-8
d111b3c665todd405054feRebased onto current
next(which now includes #22) and squashed to one commit. Only the TODO.md Completed Steps conflict needed resolving; both entries are kept. No change to the code or tests — the earlier review finding stays fixed.Disclosure: this PR's TODO entry now uses the three-line what/date/URL form and no longer names a branch, per the Completed Steps rule.
Model: opus-4-8
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.