mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-25 09:50:59 +00:00
Move a Refused Target Aside Rather Than Removing It and Wait Only for a Reader
The two-step rename fallback removed the target before its second try, and rename(2) reports the same errors for a source it cannot move, so a refusal about the source cost the caller its existing file. The target is moved aside and put back if the second step fails too. The wait for a reader holding the target open was layered on the write helper and ran on every platform and for every refusal, so a read-only target on Windows cost half a second before failing anyway, while G-code exports through rename_file() got no wait at all. It lives in rename_file() now, on Windows only, and only for a target this process could write. A failed config write clears the dirty flag as it always did, so the idle handler does not repeat it on every tick. The lock file is created readable and writable by every user, since another user sharing the data dir has to open it read-write; the check that the file behind the path is still the one opened runs at most every few seconds rather than once per preset during a scan; the physical printer loader reads under the lock; the stat headers join the existing platform include block; and the utility tests keep their file's tag.
This commit is contained in:
@@ -100,6 +100,8 @@ TEST_CASE("InstanceLock reopens a lock file that was replaced on disk", "[Instan
|
||||
{
|
||||
ScopedTemporaryFile lock_file(".lock");
|
||||
const std::string path = lock_file.string();
|
||||
const auto saved_interval = InstanceLock::identity_check_interval;
|
||||
InstanceLock::identity_check_interval = 0ms;
|
||||
{
|
||||
InstanceLock lock(path);
|
||||
REQUIRE(lock.locked());
|
||||
@@ -107,6 +109,7 @@ TEST_CASE("InstanceLock reopens a lock file that was replaced on disk", "[Instan
|
||||
|
||||
boost::filesystem::remove(path);
|
||||
InstanceLock lock(path);
|
||||
InstanceLock::identity_check_interval = saved_interval;
|
||||
REQUIRE(lock.locked());
|
||||
// Only a reopen recreates the file; a guard still holding the unlinked one
|
||||
// would leave the path missing. (The inode number itself may be reused once
|
||||
|
||||
Reference in New Issue
Block a user