mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make metadata backup a little more robust
This commit is contained in:
parent
703ea3c778
commit
87d70304bd
@ -19,7 +19,7 @@ from calibre.utils.date import parse_date, now, UNDEFINED_DATE
|
|||||||
from calibre.utils.search_query_parser import SearchQueryParser
|
from calibre.utils.search_query_parser import SearchQueryParser
|
||||||
from calibre.utils.pyparsing import ParseException
|
from calibre.utils.pyparsing import ParseException
|
||||||
from calibre.ebooks.metadata import title_sort
|
from calibre.ebooks.metadata import title_sort
|
||||||
from calibre import fit_image
|
from calibre import fit_image, prints
|
||||||
|
|
||||||
class MetadataBackup(Thread): # {{{
|
class MetadataBackup(Thread): # {{{
|
||||||
|
|
||||||
@ -39,9 +39,15 @@ class MetadataBackup(Thread): # {{{
|
|||||||
id_ = self.db.dirtied_queue.get(True, 5)
|
id_ = self.db.dirtied_queue.get(True, 5)
|
||||||
except Empty:
|
except Empty:
|
||||||
continue
|
continue
|
||||||
# If there is an exception is dump_func, we
|
except:
|
||||||
# have no way of knowing
|
# Happens during interpreter shutdown
|
||||||
self.dump_func([id_])
|
break
|
||||||
|
if self.dump_func([id_]) is None:
|
||||||
|
# An exception occured in dump_func, retry once
|
||||||
|
prints('Failed to backup metadata for id:', id_, 'once')
|
||||||
|
time.sleep(2)
|
||||||
|
if not self.dump_func([id_]):
|
||||||
|
prints('Failed to backup metadata for id:', id_, 'again, giving up')
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -575,6 +575,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
(book_id,))
|
(book_id,))
|
||||||
if commit:
|
if commit:
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
return True
|
||||||
|
|
||||||
def dirtied(self, book_ids, commit=True):
|
def dirtied(self, book_ids, commit=True):
|
||||||
self.conn.executemany(
|
self.conn.executemany(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user