From 4e460a51d7a93d21fc4a2b6f0df5ef51c31b3229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 10 Jul 2026 12:16:15 -0400 Subject: [PATCH] fix(sync): keep sync owner first-claim-wins on Windows --- crates/ely_sync_client/src/sync_owner.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/ely_sync_client/src/sync_owner.rs b/crates/ely_sync_client/src/sync_owner.rs index dd910d0..b611821 100644 --- a/crates/ely_sync_client/src/sync_owner.rs +++ b/crates/ely_sync_client/src/sync_owner.rs @@ -250,17 +250,15 @@ fn publish_owner(directory: &Dir, temporary: &str) -> io::Result<()> { .map_err(Into::into) } -#[cfg(windows)] -fn publish_owner(directory: &Dir, temporary: &str) -> io::Result<()> { - directory.rename(temporary, directory, OWNER_FILE) -} - +/// Windows `rename` replaces an existing target (MOVEFILE_REPLACE_EXISTING +/// semantics), which would let a losing concurrent claim overwrite the +/// winner. `hard_link` fails with `AlreadyExists` on every platform, so it +/// preserves first-claim-wins. #[cfg(not(any( target_vendor = "apple", target_os = "linux", target_os = "android", - target_os = "redox", - windows + target_os = "redox" )))] fn publish_owner(directory: &Dir, temporary: &str) -> io::Result<()> { directory.hard_link(temporary, directory, OWNER_FILE)?;