Skip to content

Metadata shortcut applies remote version over an unscanned local change; file contents diverge silently without conflict #10924

Closed

Description

@mxdsl

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):

  1. Device B overwrites file f with new content of the same size. B has not scanned this change yet (watcher delay, fsWatcherDelayS=10).
  2. 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.
  3. 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.
  4. 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.

  1. Create f with 1 KiB of content on A, wait until both devices are in sync.
  2. On B: overwrite f with different content of the same size. Do not trigger a scan.
  3. 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).
  4. Wait until both devices are idle, then compare the SHA-256 of f on 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

  1. added a commit that references this issue on Oct 18, 2026
    f07853b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions