refactor(history): relocate _write_history() function (#40)
Move the `_write_history()` function from `downloader.py` to `history.py`. This refactoring separates persistence logic from download orchestration, ensuring `downloader.py` focuses solely on its core responsibility.
This commit is contained in:
7 files changed
+109
-24
No files matched your search
@@ -14,7 +14,6 @@ import httpx
|
||||
|
||||
from librofm_downloader.book import Book
|
||||
from librofm_downloader.session import M4BUnavailableError
|
||||
from librofm_downloader.history import HistoryEntry
|
||||
from librofm_downloader.path import (
|
||||
_resolve_output_dir,
|
||||
needs_subdirectory,
|
||||
@@ -518,25 +517,6 @@ def download_accompanying_files(
|
||||
return downloaded
|
||||
|
||||
|
||||
def _write_history(
|
||||
history: "DownloadHistory",
|
||||
book: Book,
|
||||
fmt: str,
|
||||
path: str,
|
||||
) -> None:
|
||||
"""Write a download history entry."""
|
||||
from datetime import datetime, timezone
|
||||
|
||||
entry = HistoryEntry(
|
||||
isbn=book.isbn,
|
||||
title=book.title,
|
||||
format=fmt,
|
||||
path=path,
|
||||
downloaded_at=datetime.now(timezone.utc).isoformat(),
|
||||
)
|
||||
history.write(entry)
|
||||
|
||||
|
||||
|
||||
def rename_chapters(
|
||||
output_dir: Path | str,
|
||||
|
||||
Reference in new issue
Block a user