report and trees open the database read-write and set journal_mode #8
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
db.go:78-95builds one DSN shared byopenScanDatabase(db.go:99) andopenReportDatabase(db.go:133), and that DSN includes_pragma=journal_mode(WAL). Settingjournal_modeis a write.README §Database describes the intended deployment as a daily
scancron job maintaining/var/lib/sfdupes/db.sqlite, withreportandtrees"run interactively whenever needed". In that deployment the database is owned by the cron user (typically root) and the interactive report is not. An unprivilegedreporttherefore fails to open a database it only needs to read. The same failure hits a read-only mount, a ZFS snapshot copy, or a database on read-only media — all natural things to want to run a report against, given the whole design promises analysis never touches the scanned filesystem.Definition of done
openReportDatabaseuses a read-intent DSN:mode=roplus_pragma=query_only(1), retaining the busy timeout so a report during a concurrent scan still behaves. It must not setjournal_mode.openScanDatabasekeeps the read-write DSN unchanged, including WAL.0444and asserts bothreportandtreessucceed and produce correct output.reportandtreesrequire only read access to the database file.make checkgreen.