Pad/internal/io/pool
Greg Pomerantz 5e40378072 Fix Android: publish current mtime after the atomic-write rename
Edits on the phone were not picked up by syncthing for minutes to hours
("edited a file, but it never synced to my other devices").

Reproduced on device (Pixel 9 Pro, API 35, Syncthing-Fork, shared
storage /storage/emulated/0):

- The app's temp+rename save lands the new content (inode changes,
  bytes are correct), yet the file's mtime served through the FUSE
  layer reverts to the PREVIOUS file's mtime -- exactly, to the
  nanosecond. MediaProvider's media-scan DB row for the path is not
  updated when the staging file is renamed into place (logcat:
  "Database update failed while renaming .<name>.tmp.<pid>.<seq>")
  and the stale row wins. This reproduces for ANY writer, not just
  the app (shell temp+rename included).
- The fork's inotify watcher ignores these rename-based writes for a
  long time (a 15:48 edit reached the peer only at 16:39; five
  consecutive app writes over 6 minutes were never propagated), but
  it acts on an explicit timestamp update immediately (a touch
  synced in exactly the 10 s fsWatcherDelayS). Inotify events
  themselves are delivered fine (verified with an on-device inotify
  watcher: IN_MOVED_TO arrives).

Fix: after the rename in RealFileSystem.WriteFileAtomic, set the
file's atime/mtime to now (os.Chtimes, best-effort). utimensat
sticks through the FUSE layer and is the update the watcher reacts
to. Verified on device after the fix: edit -> peer in ~11-12 s,
mtime stays current.

Also pins the timestamp contract in
TestWriteFileAtomic_PublishesCurrentMtime (mtime is current after a
write and advances on rewrite) and documents the invariant in
architecture.md 6.5.
2026-09-02 17:12:54 -04:00
..
mock gofmt: format all remaining files with the go1.27 toolchain 2026-08-23 10:03:27 -04:00
real Fix Android: publish current mtime after the atomic-write rename 2026-09-02 17:12:54 -04:00
types gofmt: format all remaining files with the go1.27 toolchain 2026-08-23 10:03:27 -04:00
context_test.go gofmt: format all remaining files with the go1.27 toolchain 2026-08-23 10:03:27 -04:00
filesystem.go feat: virtual scrolling with chunked buffer for large files 2026-06-05 09:11:32 -04:00
result.go Fix to chunk loading policy. 2026-06-05 18:06:17 -04:00
search_test.go Add in-file search (find bar) 2026-08-20 00:02:54 -04:00
task_test.go feat: virtual scrolling with chunked buffer for large files 2026-06-05 09:11:32 -04:00
task.go gofmt: format all remaining files with the go1.27 toolchain 2026-08-23 10:03:27 -04:00
worker_pool_test.go gofmt: format all remaining files with the go1.27 toolchain 2026-08-23 10:03:27 -04:00
worker_pool.go gofmt: format all remaining files with the go1.27 toolchain 2026-08-23 10:03:27 -04:00