mirror of
https://github.com/Donkie/Spoolman.git
synced 2026-10-21 17:42:16 -05:00
A sqlite3.Connection used as a context manager is a transaction manager: it commits or rolls back on exit, it does not close the connection. Both handles stayed open past the `with` block in Database.backup(). backup_and_rotate() then unlinks and moves the .pending file it just wrote. POSIX allows unlinking a file with open handles, so this was invisible on Linux, but on Windows it raises WinError 32 and breaks both the scheduled midnight backup and the manual backup endpoint. It also leaked a pair of connections per backup on every platform. Wrap both connections in contextlib.closing instead. Connection.backup() commits on the destination internally, so nothing is lost by dropping the transaction-managing context manager. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>