mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-29 10:42:03 +01:00
logging::rotate renamed photocraft.log up the chain on every start without knowing whether another instance still wrote to it. The running instance kept its handle, so after a second launch its live log was .1.log, after a third .2.log, and a fourth launch deleted it. The instance that writes photocraft.log now holds an exclusive lock on photocraft.lock until it exits (a separate file, since Windows locks are mandatory and would keep the log itself from being opened). A start that finds that lock held leaves the chain alone and writes photocraft-<pid>.log, marked by photocraft-<pid>.lock. Those side-by-side logs are pruned to the newest KEEP once their instances have exited; a held one is never touched. Rotation and pruning run under rotate.lock so two starts at once can't interleave. On a file system without locks every start rotates as before.