Skip to content

fix: Order child deletion before parent move - #2454

Merged
shepilov merged 1 commit into
masterfrom
fix/stopped-dir-move-replaced-child
Jul 10, 2026
Merged

fix: Order child deletion before parent move#2454
shepilov merged 1 commit into
masterfrom
fix/stopped-dir-move-replaced-child

Conversation

@shepilov

@shepilov shepilov commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Problem

Fixes #2450.

The stopped-client scenario test/scenarios/move_dir_and_replace_subfile/local/stopped can create dst/file-conflict-... instead of preserving the replaced child at dst/file.

The scenario starts with src/ and src/file. While Twake Desktop is stopped, the user moves src to dst, replaces dst/file with a new file, then starts sync. The final state should keep the new child as dst/file and trash the old child identity.

Root cause

The sync dependency graph knew how to order some parent/child moves and additions, but it did not express that a deleted child from a directory move source must be applied before the parent directory move.

Without that dependency, sync could move the old remote child from src/file to dst/file as part of the parent directory move. The later upload of the new dst/file then saw an active file at the same path and was resolved as a conflict.

Changes

  • Add a same-side dependency rule in compareChanges: when a child deletion is inside a directory move source path, the deletion must run before the parent move.
  • Add unit coverage for both argument orders.
  • Add dependency-graph coverage for the full problematic order: ADD(dst/file), MOVE(src -> dst), DEL(src/file) is expanded as DEL(src/file), MOVE(src -> dst), ADD(dst/file).

@shepilov
shepilov marked this pull request as ready for review July 7, 2026 13:02
Comment thread core/sync/index.js Outdated
Comment thread core/sync/index.js Outdated
@shepilov
shepilov force-pushed the fix/stopped-dir-move-replaced-child branch from ef41d9b to a3a392e Compare July 9, 2026 12:59
Fixes #2450.

Ensure child deletions inside a moved directory source are ordered before the parent directory move, so a replaced child keeps the destination path instead of being turned into a conflict.
@shepilov
shepilov force-pushed the fix/stopped-dir-move-replaced-child branch from a3a392e to 4ba1a9e Compare July 9, 2026 13:26
@shepilov
shepilov merged commit 247e356 into master Jul 10, 2026
15 of 17 checks passed
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.

macOS stopped-client scenario creates conflict when a moved directory contains a replaced child file

2 participants