mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-03 13:19:33 +08:00
`MarginNoteStore._connect()` handed back a raw connection that every call site used as `with self._connect() as conn:`. A connection's own context manager commits or rolls back but never closes, so each call left the database file open until the garbage collector reached the connection. On Windows an open file cannot be removed. Deleting a MarginNote KB could then fail to remove its store (only a warning is logged), and connecting a library under the same name reopened that store, so devices paired with the deleted library were accepted again. Make `_connect()` a context manager that keeps the transaction and closes the connection, the same shape the session, reading and file-library stores already use. The call sites are unchanged. A new test checks that every connection the store opens is closed, so the regression fails on any platform, not only where the existing KB deletion test does.