Skip to content

fix(sync): honor remote preference during initial downloads - #3352

Open
Ausoj wants to merge 1 commit into
devspace-sh:mainfrom
Ausoj:fix/initial-sync-remote-overwrite
Open

Ausoj wants to merge 1 commit into
devspace-sh:mainfrom
Ausoj:fix/initial-sync-remote-overwrite

Conversation

@Ausoj

@Ausoj Ausoj commented Nov 9, 2026

Copy link
Copy Markdown

Summary

Fixes #3351.

mirrorRemote and preferRemote select the container's conflicting file, but the downstream unpacker has always been created with forceOverride=false. Its newer-local-mtime guard can therefore veto the selected download and leave the files different.

This change enables forceOverride for those two strategies only while Sync.initialSync runs, and resets it with defer on both success and error. The normal watcher/download path keeps its existing protection for newer local edits. preferNewest and the other initial-sync strategies retain their existing behavior; no new option or dependency is introduced.

Also included:

  • A regression test using the real downstream helper/RPC/archive path for all seven initial-sync strategies, followed by a download that must preserve a newer pending local edit.
  • A clarification in the public file-sync documentation: remote-preferred initial conflicts ignore which copy has the newer timestamp, can overwrite unsynced local work, and do not change ongoing download protection.

Validation

Before the fix, TestInitialSyncRemotePreference fails for mirrorRemote and preferRemote (got "local", want "remote"); the other five strategy cases pass. With the fix, the entire sync package passes.

Run with the vendored dependencies:

go test -mod=vendor ./pkg/devspace/sync -count=1 -timeout 120s
go test -race -mod=vendor ./pkg/devspace/sync -run '^TestInitialSyncRemotePreference$' -count=1 -timeout 90s

Both commands passed on macOS ARM64 with Go 1.25.9 (matching CI's Go 1.25 series) and 1.26.2. Go formatting and git diff --check also pass. The full documentation-site build was not run; the documentation change uses the page's existing MDX admonition syntax and changes no generated reference files.

Native CLI comparison against a disposable Colima/K3s pod, with an older remote file and a newer differing local file, --download-only --no-watch, and no local timestamp workaround:

Initial strategy Released 6.3.21 Locally built patched main
mirrorRemote Keeps stale local contents Downloads remote contents
preferRemote Keeps stale local contents Downloads remote contents
preferNewest Keeps newer local contents Keeps newer local contents

Local-only-file handling also remained correct: deleted by mirrorRemote, retained by the other two download-only configurations. Remote-only files were downloaded and remote contents were unchanged. The temporary namespace was deleted afterward; the installed CLI was not replaced.

History

The source history and reproduction are detailed in #3351. The mtime guard predates the strategy feature. Commit df377765 (introduced through #983 in February 2020) added the strategies, including preferNewest, and the forceOverride argument together, but left the downstream constructor's argument hard-coded to false. This supports a missing integration at strategy introduction, without assuming the original author's intent.

@netlify

netlify Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devspace-docs canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit c8eafb7
🔍 Latest deploy log https://app.netlify.com/projects/devspace-docs/deploys/6af20fbac337ed81abb61cd0

Force remote-preferred archive extraction only during initial sync, restoring the normal newer-local-file guard afterward. Cover all initial-sync strategies and subsequent-download protection with a real downstream archive regression test, and clarify the public documentation.

Fixes devspace-sh#3351

Signed-off-by: Ausoj <23554726+Ausoj@users.noreply.github.com>
@Ausoj
Ausoj force-pushed the fix/initial-sync-remote-overwrite branch from f92beea to c8eafb7 Compare November 9, 2026 18:23

This branch has not been deployed

No deployments
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.

bug(sync): mirrorRemote and preferRemote skip newer local files during initial sync

1 participant