mirror of
https://github.com/allankoechke/turso.git
synced 2026-12-02 09:49:09 +00:00
The sync engine's full_write handler wrote the replica metadata file in place with open(path, 'wb'), so a concurrent reader (another connection opening the same replica) could observe an empty or truncated file and fail with 'meta must be initialized before open' or a deserialization error. Write to a temp file and os.replace() it over the target, matching the atomic write the JavaScript binding already does. Tests: test_concurrent_open_existing_replica (fails on the previous truncate-in-place write, passes now) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>