From e0e7470ac6d834e4923d8521250b0342ed0695fe Mon Sep 17 00:00:00 2001 From: CaliBrain Date: Fri, 4 Apr 2025 18:10:08 -0400 Subject: [PATCH] Add Backup method to move book after download (#119) Fix #118 --- backend.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend.py b/backend.py index 4f19eb0..8a29565 100644 --- a/backend.py +++ b/backend.py @@ -142,7 +142,12 @@ def _download_book(book_id: str) -> bool: if CROSS_FILE_SYSTEM: logger.info(f"Copying book to ingest directory then renaming: {book_path} -> {final_path}.crdownload -> {final_path}") tmp_path = final_path.with_name(final_path.name + ".crdownload") - shutil.move(book_path, tmp_path) + try: + shutil.move(book_path, tmp_path) + except Exception as e: + logger.debug(f"Error moving book: {e}, will try copying instead") + shutil.copy(book_path, tmp_path) + os.remove(book_path) os.rename(tmp_path, final_path) else: logger.info(f"Moving book to ingest directory: {book_path} -> {final_path}")