This commit is contained in:
Kovid Goyal 2025-03-11 11:41:57 +05:30
parent bec4b6d6aa
commit df44a5843e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -14,6 +14,7 @@ from calibre.ptempfile import PersistentTemporaryFile, TemporaryDirectory
# Any plugins not running in the device thread must acquire this lock before # Any plugins not running in the device thread must acquire this lock before
# trying to access the Kobo database. # trying to access the Kobo database.
kobo_db_lock = RLock() kobo_db_lock = RLock()
INJECT_9P_ERROR = False
def row_factory(cursor: apsw.Cursor, row): def row_factory(cursor: apsw.Cursor, row):
@ -43,6 +44,8 @@ class Database:
self.path_on_device = self.dbpath = path_on_device self.path_on_device = self.dbpath = path_on_device
self.dbversion = 0 self.dbversion = 0
def connect(path: str = path_on_device) -> None: def connect(path: str = path_on_device) -> None:
if INJECT_9P_ERROR:
raise apsw.IOError('Fake I/O error to test 9p codepath')
with closing(apsw.Connection(path)) as conn: with closing(apsw.Connection(path)) as conn:
conn.setrowtrace(row_factory) conn.setrowtrace(row_factory)
cursor = conn.cursor() cursor = conn.cursor()