Update paths and filenames in db in a single transaction

This commit is contained in:
Kovid Goyal 2023-04-06 11:08:03 +05:30
parent 31b92d6ab8
commit dd186d060d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1775,9 +1775,10 @@ class DB:
self.copy_format_to(book_id, fmt, ofmt_fname, current_path, self.copy_format_to(book_id, fmt, ofmt_fname, current_path,
dest, windows_atomic_move=wam, use_hardlink=True) dest, windows_atomic_move=wam, use_hardlink=True)
# Update db to reflect new file locations # Update db to reflect new file locations
for fmt in formats: with self.conn:
formats_field.table.set_fname(book_id, fmt, fname, self) for fmt in formats:
path_field.table.set_path(book_id, path, self) formats_field.table.set_fname(book_id, fmt, fname, self)
path_field.table.set_path(book_id, path, self)
# Delete not needed files and directories # Delete not needed files and directories
if source_ok: if source_ok: