Skip to content

Fix Windows artifact refresh in write_file_atomic#492

Open
Ayush7Ranjan wants to merge 1 commit into
DeusData:mainfrom
Ayush7Ranjan:fix/windows-persistence
Open

Fix Windows artifact refresh in write_file_atomic#492
Ayush7Ranjan wants to merge 1 commit into
DeusData:mainfrom
Ayush7Ranjan:fix/windows-persistence

Conversation

@Ayush7Ranjan

Copy link
Copy Markdown

Summary

Fixes Windows artifact persistence for index_repository with
persistence=true.

On Windows, .codebase-memory/graph.db.zst was created on the
first run, but subsequent runs did not refresh/replace the
artifact. The root cause was src/pipeline/ artifact.c::write_file_atomic() using rename(tmp, path),
which does not reliably replace an existing destination file
on Windows.

This PR updates the atomic replace path so:

  • Windows uses MoveFileExA(tmp, path, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH)
  • POSIX keeps the existing rename(tmp, path) behavior

Verification

Built on Windows with MSYS2:

C:\msys64\usr\bin\bash.exe -lc "export HOME=/tmp; export
PATH=/mingw64/bin:/usr/bin:$PATH; cd /c/Users/aayus/OneDrive/
Desktop/opensource/codebase-memory-mcp; scripts/build.sh
CC=gcc CXX=g++"

Ran the Issue #400 reproduction twice with:

$env:CBM_CACHE_DIR = ".\.codebase-memory"
$env:CBM_PERSIST_EXPORTS = "true"

Result:

First run:
artifact_present=true
graph.db.zst exists=true
size=7586364
lastWriteUtc=2026-06-17T18:58:02.0340409Z

Second run:
artifact_present=true
graph.db.zst exists=true
size=9914129
lastWriteUtc=2026-06-17T18:58:07.9280511Z

timestamp_changed=True

## Fixes

Fixes #400

Signed-off-by: Ayush7Ranjan <aayushranjan48@gmail.com>
@Ayush7Ranjan Ayush7Ranjan force-pushed the fix/windows-persistence branch from 933e510 to 3b2bee6 Compare June 17, 2026 19:26
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