hh
This commit is contained in:
@@ -202,6 +202,8 @@ class API_folder_store:
|
||||
|
||||
DB_NAME = "medios-macina.db"
|
||||
SCHEMA_VERSION = 4
|
||||
# Global lock across all instances to prevent 'database is locked' during concurrent operations.
|
||||
_shared_db_lock = RLock()
|
||||
|
||||
def __init__(self, library_root: Path):
|
||||
"""Initialize the database at the library root.
|
||||
@@ -212,10 +214,8 @@ class API_folder_store:
|
||||
self.library_root = expand_path(library_root).resolve()
|
||||
self.db_path = self.library_root / self.DB_NAME
|
||||
self.connection: Optional[sqlite3.Connection] = None
|
||||
# sqlite3 connections are not safe for concurrent use across threads.
|
||||
# We intentionally keep a single connection per API_folder_store instance,
|
||||
# so we must serialize all DB operations on that connection.
|
||||
self._db_lock = RLock()
|
||||
# Use the shared lock
|
||||
self._db_lock = self._shared_db_lock
|
||||
self._init_db()
|
||||
|
||||
def _normalize_input_path(self, file_path: Path) -> Path:
|
||||
|
||||
Reference in New Issue
Block a user