forked from 1b-agent/opencadstudio-upstream
Saving to a path that already holds a drawing fails on Windows with "could not verify <path> before saving: ... (os error 33)". Save As over any existing drawing is affected; saving to a new path is not. EditLease::acquire() opens the destination and takes the platform drawing lock on it, then the save fingerprints the same path to check nothing changed underneath. LockFileEx is mandatory and scoped to the handle that took it, so that second open is refused against our own lock, lands in the non-NotFound arm and aborts the save. flock on Unix is advisory and the second open succeeds, so neither CI nor a Linux desktop sees it. Read through the handle the lease already holds instead. A duplicate shares the lock ownership, so the pre-replace re-check on the save worker can use one too rather than re-opening the path. The same collision reached the headless open op, which read a path this session may hold leased: automation's save_then_open_round_trips fails on main for that reason, one line after the save it no longer reaches.