A file rewritten within the same second as its recorded mtime is never backed up again #226

Open
opened 2026-10-06 01:49:45 +02:00 by clawbot · 1 comment
Collaborator

mtime is stored in whole seconds (internal/database/files.go:61, :340) and compared in whole seconds (internal/snapshot/scanner.go:1213). Suppose a file's content changes, its size stays the same, and its new mtime falls in the same second as the one already indexed. The scanner then treats the file as unchanged, and goes on doing so every run until the file changes again. This happens with a write captured by a backup and followed by another write before the second ticks over, or with a tool that preserves mtimes. Reproduced on next at 0700901: a same-size rewrite 0.8 s later, within the same second, and the next snapshot restores the old content while --verify passes.

The README promises incremental backups in which changed files are re-chunked.

Pre-1.0 rule: schema changes edit internal/database/schema/001.sql directly; no migration is added.

Definition of done

  1. mtime is stored and compared at full (nanosecond) precision.
  2. A test rewrites a file with the same size inside the same second, backs up, restores, and gets the new content.
  3. make check passes.

Model: fable-5-1 (audit); opus-5-5 (issue)

mtime is stored in whole seconds (`internal/database/files.go:61`, `:340`) and compared in whole seconds (`internal/snapshot/scanner.go:1213`). Suppose a file's content changes, its size stays the same, and its new mtime falls in the same second as the one already indexed. The scanner then treats the file as unchanged, and goes on doing so every run until the file changes again. This happens with a write captured by a backup and followed by another write before the second ticks over, or with a tool that preserves mtimes. Reproduced on `next` at `0700901`: a same-size rewrite 0.8 s later, within the same second, and the next snapshot restores the old content while `--verify` passes. The README promises incremental backups in which changed files are re-chunked. Pre-1.0 rule: schema changes edit `internal/database/schema/001.sql` directly; no migration is added. ## Definition of done 1. mtime is stored and compared at full (nanosecond) precision. 2. A test rewrites a file with the same size inside the same second, backs up, restores, and gets the new content. 3. `make check` passes. Model: fable-5-1 (audit); opus-5-5 (issue)
clawbot self-assigned this 2026-10-06 01:49:45 +02:00
Author
Collaborator

The defect reproduced on next at 49eed7a. #257 stores and compares mtime in nanoseconds since the Unix epoch and adds the backup-rewrite-backup-restore test from the definition of done.

Model: opus-5-5

The defect reproduced on `next` at `49eed7a`. https://git.eeqj.de/sneak/vaultik/pulls/257 stores and compares `mtime` in nanoseconds since the Unix epoch and adds the backup-rewrite-backup-restore test from the definition of done. Model: opus-5-5
Sign in to join this conversation.