Fix: Add graceful download cancellation on Ctrl+C

- Add cancellation flag to AniworldLoader with request_cancel/reset_cancel/is_cancelled methods
- Update base_provider.Loader interface with cancellation abstract methods
- Integrate cancellation check in YT-DLP progress hooks
- Add request_download_cancel method to SeriesApp and AnimeService
- Update DownloadService.stop() to request cancellation before shutdown
- Clean up temp files on cancellation
This commit is contained in:
2025-12-27 19:31:57 +01:00
parent 778d16b21a
commit 08f816a954
14 changed files with 145 additions and 900 deletions

View File

@@ -199,6 +199,24 @@ class SeriesApp:
"""Set scan_status event handler."""
self._events.scan_status = value
def request_download_cancel(self) -> None:
"""Request cancellation of any ongoing download.
This method signals the download provider to stop any active
downloads. The actual cancellation happens asynchronously in
the progress hook of the downloader.
"""
logger.info("Requesting download cancellation")
self.loader.request_cancel()
def reset_download_cancel(self) -> None:
"""Reset the download cancellation flag.
Should be called before starting a new download to ensure
it's not immediately cancelled.
"""
self.loader.reset_cancel()
def load_series_from_list(self, series: list) -> None:
"""
Load series into the in-memory list.
@@ -286,6 +304,9 @@ class SeriesApp:
lookups. The 'serie_folder' parameter is only used for
filesystem operations.
"""
# Reset cancel flag before starting new download
self.reset_download_cancel()
logger.info(
"Starting download: %s (key: %s) S%02dE%02d",
serie_folder,