Skip to content

ci: Wait out a share lock when replacing a file on Windows - #221

Merged
huacnlee merged 2 commits into
mainfrom
fix/windows-atomic-write-retry
Sep 15, 2026
Merged

huacnlee merged 2 commits into
mainfrom
fix/windows-atomic-write-retry

Conversation

@huacnlee

Copy link
Copy Markdown
Owner

tst_settings::fileStoreReadsWritesAndWatches failed on the Windows job of #220 and passed on the same code in #217: the second atomic write, issued right after the first, hit a sharing violation while the just-written file was still held by the virus scanner or the indexer. That is not a test problem — a user saving settings on Windows would see the same save silently fail.

FileStore::write now retries the atomic replace on Windows, eight attempts over about half a second, before reporting the error. A new Windows-only test holds the target open without sharing for 120ms from another thread and expects the write to land.

🤖 Generated with Claude Code

huacnlee and others added 2 commits September 15, 2026 18:35
Replacing a file on Windows fails with a sharing violation while the
virus scanner or the indexer still holds the one it replaces, which is
often the case a moment after it was written: the Windows CI job saw a
settings save fail right after the previous one, and a user's save
would "sometimes" do nothing the same way. The atomic write now retries
a few times over about half a second before giving up.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
MSVC's <thread> did not compile beside the Qt and Windows headers the
test already includes; QThread does the same job.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@huacnlee huacnlee changed the title Wait out a share lock when replacing a file on Windows ci: Wait out a share lock when replacing a file on Windows Sep 15, 2026
@huacnlee
huacnlee merged commit 37de49e into main Sep 15, 2026
14 checks passed
@huacnlee
huacnlee deleted the fix/windows-atomic-write-retry branch September 15, 2026 11:32
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