mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Do not try to re-open the db on IOError if the connection is in a transaction, as that will fail anyway and mask the underlying error
This commit is contained in:
parent
281b416406
commit
cc303e8ea8
@ -792,7 +792,9 @@ class DB(object):
|
|||||||
except apsw.IOError:
|
except apsw.IOError:
|
||||||
# This can happen if the computer was suspended see for example:
|
# This can happen if the computer was suspended see for example:
|
||||||
# https://bugs.launchpad.net/bugs/1286522. Try to reopen the db
|
# https://bugs.launchpad.net/bugs/1286522. Try to reopen the db
|
||||||
self.db.reopen(force=True)
|
if not self.conn.getautocommit():
|
||||||
|
raise # We are in a transaction, re-opening the db will fail anyway
|
||||||
|
self.reopen(force=True)
|
||||||
return self.conn.cursor().execute(sql, bindings)
|
return self.conn.cursor().execute(sql, bindings)
|
||||||
|
|
||||||
def executemany(self, sql, sequence_of_bindings):
|
def executemany(self, sql, sequence_of_bindings):
|
||||||
@ -802,7 +804,9 @@ class DB(object):
|
|||||||
except apsw.IOError:
|
except apsw.IOError:
|
||||||
# This can happen if the computer was suspended see for example:
|
# This can happen if the computer was suspended see for example:
|
||||||
# https://bugs.launchpad.net/bugs/1286522. Try to reopen the db
|
# https://bugs.launchpad.net/bugs/1286522. Try to reopen the db
|
||||||
self.db.reopen(force=True)
|
if not self.conn.getautocommit():
|
||||||
|
raise # We are in a transaction, re-opening the db will fail anyway
|
||||||
|
self.reopen(force=True)
|
||||||
with self.conn: # Disable autocommit mode, for performance
|
with self.conn: # Disable autocommit mode, for performance
|
||||||
return self.conn.cursor().executemany(sql, sequence_of_bindings)
|
return self.conn.cursor().executemany(sql, sequence_of_bindings)
|
||||||
|
|
||||||
@ -1589,6 +1593,7 @@ class DB(object):
|
|||||||
|
|
||||||
def has_conversion_options(self, ids, fmt='PIPE'):
|
def has_conversion_options(self, ids, fmt='PIPE'):
|
||||||
ids = frozenset(ids)
|
ids = frozenset(ids)
|
||||||
|
with self.conn:
|
||||||
self.execute('DROP TABLE IF EXISTS conversion_options_temp; CREATE TEMP TABLE conversion_options_temp (id INTEGER PRIMARY KEY);')
|
self.execute('DROP TABLE IF EXISTS conversion_options_temp; CREATE TEMP TABLE conversion_options_temp (id INTEGER PRIMARY KEY);')
|
||||||
self.executemany('INSERT INTO conversion_options_temp VALUES (?)', [(x,) for x in ids])
|
self.executemany('INSERT INTO conversion_options_temp VALUES (?)', [(x,) for x in ids])
|
||||||
for (book_id,) in self.conn.get(
|
for (book_id,) in self.conn.get(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user