mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Also dont print traceback if db is closed
This commit is contained in:
parent
5d92cfadd1
commit
7dbefdf117
@ -403,6 +403,7 @@ class DB(object):
|
||||
def __init__(self, library_path, default_prefs=None, read_only=False,
|
||||
restore_all_prefs=False, progress_callback=lambda x, y:True,
|
||||
load_user_formatter_functions=True):
|
||||
self.is_closed = False
|
||||
try:
|
||||
if isbytestring(library_path):
|
||||
library_path = library_path.decode(filesystem_encoding)
|
||||
@ -907,6 +908,7 @@ class DB(object):
|
||||
def conn(self):
|
||||
if self._conn is None:
|
||||
self._conn = Connection(self.dbpath)
|
||||
self.is_closed = False
|
||||
if self._exists and self.user_version == 0:
|
||||
self._conn.close()
|
||||
os.remove(self.dbpath)
|
||||
@ -1148,6 +1150,7 @@ class DB(object):
|
||||
pass
|
||||
self._conn.close(force)
|
||||
del self._conn
|
||||
self.is_closed = True
|
||||
|
||||
def reopen(self, force=False):
|
||||
self.close(force=force, unload_formatter_functions=False)
|
||||
|
@ -62,7 +62,7 @@ class MetadataBackup(Thread):
|
||||
try:
|
||||
self.db.check_dirtied_annotations()
|
||||
except Exception:
|
||||
if self.stop_running.is_set():
|
||||
if self.stop_running.is_set() or self.db.is_closed:
|
||||
return
|
||||
traceback.print_exc()
|
||||
try:
|
||||
|
@ -2127,6 +2127,10 @@ class Cache(object):
|
||||
traceback.print_exc()
|
||||
self.backend.close()
|
||||
|
||||
@property
|
||||
def is_closed(self):
|
||||
return self.backend.is_closed
|
||||
|
||||
@write_api
|
||||
def restore_book(self, book_id, mi, last_modified, path, formats, annotations=()):
|
||||
''' Restore the book entry in the database for a book that already exists on the filesystem '''
|
||||
|
Loading…
x
Reference in New Issue
Block a user