From 3184be0c42005a45704a1b1f69a49820d624b23e Mon Sep 17 00:00:00 2001 From: mmynk Date: Sun, 14 Dec 2025 18:25:50 -0800 Subject: [PATCH] fix data directory creation when epub is in different directory When running reader3.py with an epub file from a different directory, the data directory was created relative to the epub file's location instead of the current working directory where the server expects it. This caused the server to show no content. Now creates the data directory in pwd to fix the issue regardless of wherever the epub file is located. --- reader3.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reader3.py b/reader3.py index d0b9d3f..a9db5fd 100644 --- a/reader3.py +++ b/reader3.py @@ -8,6 +8,7 @@ from dataclasses import dataclass, field from typing import List, Dict, Optional, Any from datetime import datetime +from pathlib import Path from urllib.parse import unquote import ebooklib @@ -300,8 +301,10 @@ def save_to_pickle(book: Book, output_dir: str): sys.exit(1) epub_file = sys.argv[1] - assert os.path.exists(epub_file), "File not found." - out_dir = os.path.splitext(epub_file)[0] + "_data" + epub_path = Path(epub_file) + assert epub_path.exists(), "File not found." + out_dir = Path() / epub_path.stem + out_dir = str(out_dir) + "_data" book_obj = process_epub(epub_file, out_dir) save_to_pickle(book_obj, out_dir)