diff --git a/docs/instructions.md b/docs/instructions.md index 2e33148..62d5e4a 100644 --- a/docs/instructions.md +++ b/docs/instructions.md @@ -121,4 +121,96 @@ For each task completed: --- -~~fix: on new added animes for the nfo the property plot is not loaded and written in nfo. make sure all properties are written on nfo creation~~ ✅ DONE +fix: download not working: + +elf.\_progress_service.update_progress( + +File "/app/src/server/services/progress_service.py", line 369, in update_progress + + raise ProgressServiceError( + +src.server.services.progress_service.ProgressServiceError: Progress with id 'download_queue' not found + +2026-03-11 15:15:42 [info ] Processing next item from queue item_id=108 remaining=2 serie=I Was Reincarnated as the 7th Prince So I Can Take My Time Perfecting My Magical Ability + +2026-03-11 15:15:42 [error ] Error in queue processing loop error=Progress with id 'download_queue' not found + +Traceback (most recent call last): + +File "/app/src/server/services/download_service.py", line 716, in \_process_queue + + await self._progress_service.update_progress( + +File "/app/src/server/services/progress_service.py", line 369, in update_progress + + raise ProgressServiceError( + +src.server.services.progress_service.ProgressServiceError: Progress with id 'download_queue' not found + +2026-03-11 15:15:43 [info ] Processing next item from queue item_id=109 remaining=1 serie=I Was Reincarnated as the 7th Prince So I Can Take My Time Perfecting My Magical Ability + +2026-03-11 15:15:43 [error ] Error in queue processing loop error=Progress with id 'download_queue' not found + +Traceback (most recent call last): + +File "/app/src/server/services/download_service.py", line 716, in \_process_queue + + await self._progress_service.update_progress( + +File "/app/src/server/services/progress_service.py", line 369, in update_progress + + raise ProgressServiceError( + +src.server.services.progress_service.ProgressServiceError: Progress with id 'download_queue' not found + +2026-03-11 15:15:44 [info ] Processing next item from queue item_id=110 remaining=0 serie=I Was Reincarnated as the 7th Prince So I Can Take My Time Perfecting My Magical Ability + +2026-03-11 15:15:44 [error ] Error in queue processing loop error=Progress with id 'download_queue' not found + +Traceback (most recent call last): + +File "/app/src/server/services/download_service.py", line 716, in \_process_queue + + await self._progress_service.update_progress( + +File "/app/src/server/services/progress_service.py", line 369, in update_progress + + raise ProgressServiceError( + +src.server.services.progress_service.ProgressServiceError: Progress with id 'download_queue' not found + +2026-03-11 15:15:45 [info ] Queue processing completed - all items processed + +ERROR: Task exception was never retrieved + +future: exception=ProgressServiceError("Progress with id 'download_queue' not found")> + +Traceback (most recent call last): + +File "/app/src/server/services/download_service.py", line 755, in \_process_queue + + await self._progress_service.complete_progress( + +File "/app/src/server/services/progress_service.py", line 446, in complete_progress + + raise ProgressServiceError( + +src.server.services.progress_service.ProgressServiceError: Progress with id 'download_queue' not found + +2026-03-11 15:15:46 [info ] Queue processing completed - all items processed + +ERROR: Task exception was never retrieved + +future: exception=ProgressServiceError("Progress with id 'download_queue' not found")> + +Traceback (most recent call last): + +File "/app/src/server/services/download_service.py", line 755, in \_process_queue + + await self._progress_service.complete_progress( + +File "/app/src/server/services/progress_service.py", line 446, in complete_progress + + raise ProgressServiceError( + +src.server.services.progress_service.ProgressServiceError: Progress with id 'download_queue' not found diff --git a/src/server/services/download_service.py b/src/server/services/download_service.py index 475d0c2..ab055a3 100644 --- a/src/server/services/download_service.py +++ b/src/server/services/download_service.py @@ -395,7 +395,16 @@ class DownloadService: ) self._queue_progress_initialized = True except Exception as e: - logger.error("Failed to initialize queue progress: %s", e) + # If the entry already exists (e.g. from a concurrent task), + # treat that as success — the progress is usable. + from src.server.services.progress_service import ProgressServiceError + if isinstance(e, ProgressServiceError) and "already exists" in str(e): + logger.debug( + "Queue progress already initialized by concurrent task" + ) + self._queue_progress_initialized = True + else: + logger.error("Failed to initialize queue progress: %s", e) def _add_to_pending_queue( self, item: DownloadItem, front: bool = False @@ -759,8 +768,12 @@ class DownloadService: "queue_status": queue_status.model_dump(mode="json") }, ) + # Reset flag so next queue run re-creates the progress entry + self._queue_progress_initialized = False else: logger.info("Queue processing stopped by user") + # Reset flag so next queue run re-creates the progress entry + self._queue_progress_initialized = False async def start_next_download(self) -> Optional[str]: """Legacy method - redirects to start_queue_processing. @@ -781,18 +794,21 @@ class DownloadService: self._is_stopped = True logger.info("Download processing stopped") - # Notify via progress service - queue_status = await self.get_queue_status() - await self._progress_service.update_progress( - progress_id="download_queue", - message="Queue processing stopped", - metadata={ - "action": "queue_stopped", - "is_stopped": True, - "queue_status": queue_status.model_dump(mode="json"), - }, - force_broadcast=True, - ) + # Notify via progress service (guard against entry not existing) + try: + queue_status = await self.get_queue_status() + await self._progress_service.update_progress( + progress_id="download_queue", + message="Queue processing stopped", + metadata={ + "action": "queue_stopped", + "is_stopped": True, + "queue_status": queue_status.model_dump(mode="json"), + }, + force_broadcast=True, + ) + except Exception as e: + logger.warning("Could not update queue progress on stop: %s", e) async def get_queue_status(self) -> QueueStatus: """Get current status of all queues.