mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-24 09:23:27 +00:00
Windows refuses to replace a file that another process holds open without FILE_SHARE_DELETE, which is how the C runtime opens files for reading, so the atomic write could fail against a concurrent reader and drop the save where the old in-place write had succeeded. Lock the readers that were still outside the guard, Preset::reload() and the physical printer loader and writer, and when the rename still fails that way, log it and write in place as before; losing the save is worse than a torn read. Report the OS error from a failed write instead of a generic I/O error. Each leaf guard paid the full two-second wait on its own, so a bulk save against an instance holding the lock for a long scan stalled once per preset while holding the preset collection mutex. After a timed-out wait the same lock file is not waited on again for ten seconds. Read-only scans never rewrite or delete and many CLI jobs may share one data dir, so they take no lock and no longer queue behind each other or log about writing. Take the bundle metadata guard beside the write rather than while the JSON is built, state the lock-order rule in the header, and give the tests a temporary file rather than a directory, since the process keeps the lock file open and a directory holding it cannot be removed on Windows.
OrcaSlicer tests
Building, running and writing tests is documented on the wiki, under How to Test.
Two files here rather than there, because coding agents only read what is in the repository: