mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-25 10:56:48 -06:00
A child process forked before its exec inherits the run's open descriptors, and a flock lasts while any descriptor for the file is open. A crashed run whose folder lock was still held by such a child read as a run that was still going, so recover_all skipped it and its unsaved documents were not opened at the next start. The desktop app's tests failed intermittently for the same reason whenever another test spawned a process in parallel (the reduced-motion read spawns gsettings on Linux and the BSDs): recovery_tests failed in 23 of 60 runs of the whole binary and never on its own. Taking a folder's lock now retries try_lock briefly, so a lock that frees itself is no longer read as a live run while a run that really is running still keeps its folder. Regression test: a_lock_freed_a_moment_later_is_not_a_run_that_is_still_going holds the crashed run's lock on a second descriptor, the way a forked child does, and frees it shortly after; the copies come back. The recovery tests that collide with a spawning test went from 8 failures in 10 runs to 0 in 10.