mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 01:33:30 +02:00
Fix metadata backup not being written if book directory does not exist
This commit is contained in:
parent
e105493d78
commit
98924814ad
2 changed files with 9 additions and 2 deletions
|
|
@ -1390,8 +1390,13 @@ def update_path(self, book_id, title, author, path_field, formats_field):
|
|||
|
||||
def write_backup(self, path, raw):
|
||||
path = os.path.abspath(os.path.join(self.library_path, path, 'metadata.opf'))
|
||||
with lopen(path, 'wb') as f:
|
||||
f.write(raw)
|
||||
try:
|
||||
with lopen(path, 'wb') as f:
|
||||
f.write(raw)
|
||||
except EnvironmentError:
|
||||
os.makedirs(os.path.dirname(path))
|
||||
with lopen(path, 'wb') as f:
|
||||
f.write(raw)
|
||||
|
||||
def read_backup(self, path):
|
||||
path = os.path.abspath(os.path.join(self.library_path, path, 'metadata.opf'))
|
||||
|
|
|
|||
|
|
@ -100,11 +100,13 @@ def do_one(self):
|
|||
self.db.write_backup(book_id, raw)
|
||||
except:
|
||||
prints('Failed to write backup metadata for id:', book_id, 'once')
|
||||
traceback.print_exc()
|
||||
self.wait(self.interval)
|
||||
try:
|
||||
self.db.write_backup(book_id, raw)
|
||||
except:
|
||||
prints('Failed to write backup metadata for id:', book_id, 'again, giving up')
|
||||
traceback.print_exc()
|
||||
return
|
||||
|
||||
self.db.clear_dirtied(book_id, sequence)
|
||||
|
|
|
|||
Loading…
Reference in a new issue