When exporting very large libraries fix failures due to busy errors. Fixes #1779664 [Error-message when exporting library for Backup](https://bugs.launchpad.net/calibre/+bug/1779664)

This commit is contained in:
Kovid Goyal 2018-07-02 18:01:13 +05:30
parent a0b400764d
commit 86dab6d6cc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1788,14 +1788,13 @@ class DB(object):
self.executemany('INSERT INTO data (book,format,uncompressed_size,name) VALUES (?,?,?,?)', vals)
def backup_database(self, path):
# We have to open a new connection to self.dbpath, until this issue is fixed:
# https://github.com/rogerbinns/apsw/issues/199
dest_db = apsw.Connection(path)
source = apsw.Connection(self.dbpath)
with dest_db.backup('main', source, 'main') as b:
with dest_db.backup('main', self.conn, 'main') as b:
while not b.done:
b.step(100)
source.close()
try:
b.step(100)
except apsw.BusyError:
pass
dest_db.cursor().execute('DELETE FROM metadata_dirtied; VACUUM;')
dest_db.close()