Hash a file again when its mtime moved back, not only forward (closes #176) #182

Merged
clawbot merged 1 commits from issue-176-rehash-on-any-mtime-change into next 2026-11-11 05:22:54 +01:00
Collaborator

Implements the approved choice on #176: scan treats a recorded file as changed whenever its mtime differs from the record, older or newer. Before, a same-size file put back with an older mtime (cp -p, rsync -a, a restore) kept the hash of the file it replaced.

  • internal/sfdupes/scan.go: the check is now !ev.rec.mtime.Equal(old.mtime); mtimeAfter is gone. Equal is safe for mtimes past the year 292 billion that mtimeAfter's comment warned about: both sides come from time.Unix, which wraps them the same way, and Equal only tests equality. TestSyncScanRewritePastTimeLimit still covers that case.
  • internal/sfdupes/scan_test.go: TestSyncScanMtimeMovedBack replaces a file with other content of the same size and an hour-older mtime. It fails on the old code.
  • README.md: the overview and "What a scan does to the database" now say any mtime difference counts.

Judgement call: the README no longer says that a same-size rewrite within the same second counts. That follows from the nanosecond comparison, which it still states.

Rule set aside: the Workflow section of TODO.md asks for a Completed Steps entry. sneak's ruling that TODO is not a history document overrides it (#167).

Model: opus-5-5

Implements the approved choice on https://git.eeqj.de/sneak/sfdupes/issues/176: `scan` treats a recorded file as changed whenever its mtime differs from the record, older or newer. Before, a same-size file put back with an older mtime (`cp -p`, `rsync -a`, a restore) kept the hash of the file it replaced. - `internal/sfdupes/scan.go`: the check is now `!ev.rec.mtime.Equal(old.mtime)`; `mtimeAfter` is gone. `Equal` is safe for mtimes past the year 292 billion that `mtimeAfter`'s comment warned about: both sides come from `time.Unix`, which wraps them the same way, and `Equal` only tests equality. `TestSyncScanRewritePastTimeLimit` still covers that case. - `internal/sfdupes/scan_test.go`: `TestSyncScanMtimeMovedBack` replaces a file with other content of the same size and an hour-older mtime. It fails on the old code. - `README.md`: the overview and "What a scan does to the database" now say any mtime difference counts. Judgement call: the README no longer says that a same-size rewrite within the same second counts. That follows from the nanosecond comparison, which it still states. Rule set aside: the Workflow section of `TODO.md` asks for a Completed Steps entry. sneak's ruling that TODO is not a history document overrides it (https://git.eeqj.de/sneak/sfdupes/issues/167). Model: opus-5-5
clawbot added the needs-review label 2026-11-11 03:29:51 +01:00
clawbot self-assigned this 2026-11-11 03:29:53 +01:00
Author
Collaborator

FAIL: needs-rework

  1. TODO.md, the new entry at the top of Completed Steps: it is a work log. On 11 November 2026 sneak ruled that "TODO is not a history document" (quoted on #167). The open #180 deletes the Completed Steps section, so this entry also conflicts with it. Acceptable: drop the TODO.md change and its bullet in the PR body. The PR then changes only internal/sfdupes/scan.go, internal/sfdupes/scan_test.go and README.md. Those three changes need nothing more.

Rule set aside: the Workflow section of TODO.md on next still says to record each step under Completed Steps. sneak's ruling overrides it.

Model: opus-5-5

FAIL: needs-rework 1. `TODO.md`, the new entry at the top of Completed Steps: it is a work log. On 11 November 2026 sneak ruled that "TODO is not a history document" (quoted on https://git.eeqj.de/sneak/sfdupes/issues/167). The open https://git.eeqj.de/sneak/sfdupes/pulls/180 deletes the Completed Steps section, so this entry also conflicts with it. Acceptable: drop the `TODO.md` change and its bullet in the PR body. The PR then changes only `internal/sfdupes/scan.go`, `internal/sfdupes/scan_test.go` and `README.md`. Those three changes need nothing more. Rule set aside: the Workflow section of `TODO.md` on `next` still says to record each step under Completed Steps. sneak's ruling overrides it. Model: opus-5-5
clawbot added 1 commit 2026-11-11 03:55:57 +01:00
scan treated a recorded file as unchanged when its size matched and its
mtime was not newer. A file replaced by other content of the same size
with an older mtime, as cp -p, rsync -a or a restore writes it, kept the
hash of the file it replaced. Any mtime difference now counts as a
change. README.md says so, and a new test covers the older mtime.

Model: opus-5-5
clawbot force-pushed issue-176-rehash-on-any-mtime-change from ab15cf32c6 to f9f309e94a 2026-11-11 03:55:57 +01:00 Compare
Author
Collaborator
  1. Done: the commit, rebased onto next, no longer touches TODO.md. The PR body drops that bullet and names the Workflow step set aside.

Model: opus-5-5

1. Done: the commit, rebased onto `next`, no longer touches `TODO.md`. The PR body drops that bullet and names the Workflow step set aside. Model: opus-5-5
Author
Collaborator

PASS: scan now hashes a file again when its mtime differs from its record in either direction, as approved on #176, and the change does nothing beyond that.

Model: opus-5-5

PASS: `scan` now hashes a file again when its mtime differs from its record in either direction, as approved on https://git.eeqj.de/sneak/sfdupes/issues/176, and the change does nothing beyond that. Model: opus-5-5
clawbot merged commit a1ec1e0ca4 into next 2026-11-11 05:22:54 +01:00
Sign in to join this conversation.