Skip to content

feat(sync): check a conflict against the bytes before asking - #78

Merged
michvllni merged 1 commit into
mainfrom
feat/compare-before-conflict
Nov 8, 2026
Merged

michvllni merged 1 commit into
mainfrom
feat/compare-before-conflict

Conversation

@michvllni

@michvllni michvllni commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Why

SMB, FTP and WebDAV tag files by size and time, so a copy made separately never matches: a remote added with the saves already on it, or a file copied back by hand, asked once per file. Drive and Dropbox already settle this with their content hash.

What changes

  • A conflict is checked against the bytes before anyone is asked. With two or more sides changed and the 3DS holding a copy, each changed remote without a content hash is checked (sameAsLocalCopy() in syncengine.cpp):
    • Different sizes: if the remote's size is known and differs, it is a real conflict, settled without a download.
    • Otherwise: the remote copy is downloaded to <save>.compare<n>.3dstmp and compared byte for byte (compareFiles() in utils/fsutil).
    • A match: that remote drops out of the prompt and is recorded as in step, with nothing copied.
    • A failed or over-size check: the conflict stays as it was.
  • A copy that differs is kept. If that side wins the prompt, it is moved into place instead of being downloaded again. FetchedCopies removes unused copies however syncFile() returns.
  • The settings, both optional:
    [Sync]
    CompareUpTo=4096         ; KB, the default (4 MB); 0 = no limit
    CompareConflicts=false   ; never compare: every such conflict is asked about
    A bad value is a startup issue, and the default applies until it is fixed.
  • Remote file sizes: RemoteFileInfo::size is new, filled in by FTP (SIZE), SMB, and WebDAV (getcontentlength).
  • The local walk skips names ending in .3dstmp, so a download or comparison cut short is never synced as a save.
  • The configurator: step 2 has a "Conflicts" block for both settings, shown when an SMB, FTP or WebDAV remote is configured. inifile.js reads and writes [Sync], writes it only when it says something, and keeps its other lines.
  • README and AGENTS.md describe all of it.

Tests

  • make -C tests: 279 pass. 15 are new (F=compare):

    • the same bytes are no conflict, and the file stays in step on the next run;
    • different bytes are asked about;
    • a different size needs no download;
    • without a size, the bytes decide;
    • a file over the limit is asked about;
    • no limit compares any size;
    • an entry built in code never compares;
    • a content hash is trusted without a download;
    • a failed download is asked about;
    • both sides changed to the same bytes;
    • the compared copy is reused when the remote wins and dropped when the 3DS wins;
    • with several remotes, only the winner's copy is kept;
    • compareFiles();
    • both settings.

    Plus WebDAV's size parsing in test_remoteparse.

  • node --test tests/configurator/*.test.js: two new cases for writing and reading [Sync].

  • The 3DS build has no warnings.

Not yet tested

  • On a console. A test build with steps against testinfra/ exists.
  • The configurator's new block has not been looked at in a browser.

🤖 Generated with Claude Code

- SMB, FTP and WebDAV tag files by size and time, which a copy made
  separately never matches, so a remote added with the saves already on
  it asked once per file.  Drive and Dropbox already settle this with a
  content hash.
- With two or more sides changed and the 3DS holding a copy, each changed
  remote without a content hash is checked: a known size that differs
  settles it; otherwise the remote copy is downloaded beside the save and
  compared byte for byte.  A match drops out of the prompt and is recorded
  as in step, with nothing copied.
- A copy that differs is kept: if that side wins the prompt it is moved
  into place instead of being downloaded again.  Unused copies are
  removed however the decision ends.
- [Sync] CompareUpTo= (KB, default 4096, 0 = no limit) bounds the
  download made before the prompt; CompareConflicts=false turns the check
  off.  A bad value is a startup issue and the default applies.
- FTP (SIZE), SMB and WebDAV (getcontentlength) now report a file's size.
- The local walk skips names ending in .3dstmp, so a download or
  comparison cut short is never synced as a save.
- The configurator's step 2 has a Conflicts block for both settings,
  shown when an SMB, FTP or WebDAV remote is configured; inifile.js reads
  and writes [Sync] and keeps its other lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michvllni
michvllni force-pushed the feat/compare-before-conflict branch from 9803443 to 2c8e55d Compare November 8, 2026 20:33
@michvllni
michvllni merged commit c38016b into main Nov 8, 2026
7 checks passed
@michvllni
michvllni deleted the feat/compare-before-conflict branch November 8, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant