From 704dcb3e587eed371ede66f54434ea92c3270f86 Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Sun, 9 Aug 2020 00:55:56 -0400 Subject: [PATCH 1/2] Move assignment of `new_coverpath` With the assignment originally being within the try, if the try failed, the exception wouldn't have access to the value --- cps/editbooks.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cps/editbooks.py b/cps/editbooks.py index f14da1bf..ee260e66 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -223,7 +223,6 @@ def delete_book(book_id, book_format): getattr(book, cc_string).remove(del_cc) log.debug('remove ' + str(c.id)) calibre_db.session.delete(del_cc) - calibre_db.session.commit() else: modify_database_object([u''], getattr(book, cc_string), db.cc_classes[c.id], calibre_db.session, 'custom') @@ -833,8 +832,8 @@ def upload(): # move cover to final directory, including book id if has_cover: + new_coverpath = os.path.join(config.config_calibre_dir, db_book.path, "cover.jpg") try: - new_coverpath = os.path.join(config.config_calibre_dir, db_book.path, "cover.jpg") copyfile(meta.cover, new_coverpath) os.unlink(meta.cover) except OSError as e: From 28bfb06c67a6c5c1a3230f8e73be336d1dfc9111 Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Sun, 9 Aug 2020 00:57:30 -0400 Subject: [PATCH 2/2] Revert the deletion of another line This was done by mistake, whoops! --- cps/editbooks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cps/editbooks.py b/cps/editbooks.py index ee260e66..7330572b 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -223,6 +223,7 @@ def delete_book(book_id, book_format): getattr(book, cc_string).remove(del_cc) log.debug('remove ' + str(c.id)) calibre_db.session.delete(del_cc) + calibre_db.session.commit() else: modify_database_object([u''], getattr(book, cc_string), db.cc_classes[c.id], calibre_db.session, 'custom')