Repository navigation
Description
What happened?
Two send-receive devices can end up with permanently different content for the same file, while both report the folder as 100 % in sync, no conflict copy is created, and a rescan finds nothing.
Sequence (reproduced 6 of 6 times, plus once by accident on a busy file):
- Device B overwrites file
fwith new content of the same size. B has not scanned this change yet (watcher delay,fsWatcherDelayS=10). - About 1 s later, device A changes only the mtime of
f(same content as before) and scans. A announces a new version whose blocks are unchanged. - B pulls. Because the announced blocks equal the blocks of B's last scanned version in the database, the puller takes the metadata shortcut (
ItemFinished action=metadata). It applies A's mtime to B's file and records A's version as B's local version. - B's on-disk content is still B's new content, but size and mtime now match the database entry. When the watcher fires, the scan sees no change. A manual rescan also sees no change.
End state: A has content X, B has content Y, same size, same mtime, both devices idle, completion 100 %, no .sync-conflict-* file. It stayed like this for over 40 minutes and two restarts.
What did you expect?
The same as on the normal pull path: before applying a remote version, notice that the local file was modified but not rescanned (errModified, "file modified but not rescanned; will try again later"), rescan it, and then either sync it or create a conflict copy.
Probable cause (from reading v2.1.5)
In lib/model/folder_sendrecv.go, processNeeded calls shortcutFile when file.BlocksEqual(curFile), where curFile is the database entry. shortcutFile sets permissions, platform data and mtime and sends dbUpdateShortcutFile, but never compares the file on disk with curFile (unlike performFinish and checkToBeDeleted, which use scanIfItemChanged). This looks like the regular-file counterpart of #5571, which added these checks for directories and symlinks. The code path is unchanged on main as of d70d210 (v2.1.7-rc.2).
A possible fix: in the shortcut path, Lstat the file and compare it with curFile (size, mtime, permissions) as scanIfItemChanged does; if it differs, schedule a scan and skip the shortcut.
Steps to reproduce
Two devices, one shared send-receive folder, default settings except fsWatcherDelayS=10.
- Create
fwith 1 KiB of content on A, wait until both devices are in sync. - On B: overwrite
fwith different content of the same size. Do not trigger a scan. - Within ~1 s on A:
touch f(mtime only), then trigger a scan of the folder on A (POST /rest/db/scan?folder=<id>&sub=f). - Wait until both devices are idle, then compare the SHA-256 of
fon A and B, and trigger a rescan on B.
Result: hashes differ, both sides report 100 %, no conflict copy.
Syncthing version
v2.1.5 on both devices
Platform & operating system
Windows 11 (amd64) and macOS 26.6.2 (arm64), LAN and over Tailscale
Browser version
n/a (REST API only)
Relevant log output
B: ItemStarted {"action":"metadata","item":"f","type":"file"}
B: ItemFinished {"action":"metadata","error":null,"item":"f","type":"file"}
B: INFO: Updated file metadata (folder=... file=f)
Activity
fix(model): verify local change before applying metadata shortcut (fixes
chore(deps): update syncthing/syncthing docker tag to v2.1.7 (#13)