From fadd4973da71e2098e05ee3520d7c23b8df7004d Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 30 Oct 2025 21:22:43 +0100 Subject: [PATCH] cleanup unused methods --- data/config.json | 2 +- data/download_queue.json | 2 +- src/server/api/download.py | 96 ------------------------- src/server/fastapi_app.py | 2 - src/server/web/static/js/queue.js | 36 ---------- src/server/web/templates/queue.html | 10 --- tests/integration/test_auth_flow.py | 4 +- tests/integration/test_download_flow.py | 16 ++--- 8 files changed, 12 insertions(+), 156 deletions(-) diff --git a/data/config.json b/data/config.json index 1d7f52b..81a0f8f 100644 --- a/data/config.json +++ b/data/config.json @@ -17,7 +17,7 @@ "keep_days": 30 }, "other": { - "master_password_hash": "$pbkdf2-sha256$29000$DwGg9P5fS4mxNiZEyBnjvA$prwrz.LHaPTVVqtZMVAXPkw3GclQrCiIfa35SvcV2RA", + "master_password_hash": "$pbkdf2-sha256$29000$jjEmREjJWWsNYSyFMObcOw$7xzy6ahn4apmpLcAyxr2JKTxTmXd8zxtBgpB6uVGdDE", "anime_directory": "/home/lukas/Volume/serien/" }, "version": "1.0.0" diff --git a/data/download_queue.json b/data/download_queue.json index 62d4a00..5313acc 100644 --- a/data/download_queue.json +++ b/data/download_queue.json @@ -2,5 +2,5 @@ "pending": [], "active": [], "failed": [], - "timestamp": "2025-10-30T20:10:45.815431+00:00" + "timestamp": "2025-10-30T20:21:10.438027+00:00" } \ No newline at end of file diff --git a/src/server/api/download.py b/src/server/api/download.py index 2631b87..aa9c86a 100644 --- a/src/server/api/download.py +++ b/src/server/api/download.py @@ -18,9 +18,6 @@ from src.server.utils.dependencies import get_download_service, require_auth router = APIRouter(prefix="/api/queue", tags=["download"]) -# Secondary router for test compatibility (no prefix) -downloads_router = APIRouter(prefix="/api", tags=["download"]) - @router.get("/status", response_model=QueueStatusResponse) async def get_queue_status( @@ -467,52 +464,6 @@ async def resume_queue( ) -# Backwards-compatible control endpoints (some integration tests and older -# clients call `/api/queue/control/`). These simply proxy to the -# existing handlers above to avoid duplicating service logic. - - -@router.post("/control/start", status_code=status.HTTP_200_OK) -async def control_start( - _: dict = Depends(require_auth), - download_service: DownloadService = Depends(get_download_service), -): - return await start_queue(_, download_service) - - -@router.post("/control/stop", status_code=status.HTTP_200_OK) -async def control_stop( - _: dict = Depends(require_auth), - download_service: DownloadService = Depends(get_download_service), -): - return await stop_queue(_, download_service) - - -@router.post("/control/pause", status_code=status.HTTP_200_OK) -async def control_pause( - _: dict = Depends(require_auth), - download_service: DownloadService = Depends(get_download_service), -): - return await pause_queue(_, download_service) - - -@router.post("/control/resume", status_code=status.HTTP_200_OK) -async def control_resume( - _: dict = Depends(require_auth), - download_service: DownloadService = Depends(get_download_service), -): - return await resume_queue(_, download_service) - - -@router.post("/control/clear_completed", status_code=status.HTTP_200_OK) -async def control_clear_completed( - _: dict = Depends(require_auth), - download_service: DownloadService = Depends(get_download_service), -): - # Call the existing clear_completed implementation which returns a dict - return await clear_completed(_, download_service) - - @router.post("/reorder", status_code=status.HTTP_200_OK) async def reorder_queue( request: dict, @@ -663,50 +614,3 @@ async def retry_failed( status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=f"Failed to retry downloads: {str(e)}", ) - - -# Alternative endpoint for compatibility with input validation tests -@downloads_router.post( - "/downloads", - status_code=status.HTTP_201_CREATED, - include_in_schema=False, -) -async def add_download_item( - request: DownloadRequest, - download_service: DownloadService = Depends(get_download_service), -): - """Add item to download queue (alternative endpoint for testing). - - This is an alias for POST /api/queue/add for input validation testing. - Uses the same validation logic as the main queue endpoint. - Note: Authentication check removed for input validation testing. - """ - # Validate that values are not negative - try: - anime_id_val = int(request.anime_id) - if anime_id_val < 0: - raise HTTPException( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, - detail="anime_id must be a positive number", - ) - except (ValueError, TypeError): - raise HTTPException( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, - detail="anime_id must be a valid number", - ) - - # Validate episode numbers if provided - if request.episodes: - for ep in request.episodes: - if ep < 0: - raise HTTPException( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, - detail="Episode numbers must be positive", - ) - - return { - "status": "success", - "message": "Download request validated", - } - - diff --git a/src/server/fastapi_app.py b/src/server/fastapi_app.py index aa37973..08600f0 100644 --- a/src/server/fastapi_app.py +++ b/src/server/fastapi_app.py @@ -22,7 +22,6 @@ from src.infrastructure.logging import setup_logging from src.server.api.anime import router as anime_router from src.server.api.auth import router as auth_router from src.server.api.config import router as config_router -from src.server.api.download import downloads_router from src.server.api.download import router as download_router from src.server.api.scheduler import router as scheduler_router from src.server.api.websocket import router as websocket_router @@ -168,7 +167,6 @@ app.include_router(config_router) app.include_router(scheduler_router) app.include_router(anime_router) app.include_router(download_router) -app.include_router(downloads_router) # Alias for input validation tests app.include_router(websocket_router) # Register exception handlers diff --git a/src/server/web/static/js/queue.js b/src/server/web/static/js/queue.js index 37ae169..0b97467 100644 --- a/src/server/web/static/js/queue.js +++ b/src/server/web/static/js/queue.js @@ -147,10 +147,6 @@ class QueueManager { this.retryAllFailed(); }); - document.getElementById('reorder-queue-btn').addEventListener('click', () => { - this.toggleReorderMode(); - }); - // Download controls document.getElementById('start-queue-btn').addEventListener('click', () => { this.startDownloadQueue(); @@ -160,14 +156,6 @@ class QueueManager { this.stopDownloadQueue(); }); - document.getElementById('pause-all-btn').addEventListener('click', () => { - this.pauseAllDownloads(); - }); - - document.getElementById('resume-all-btn').addEventListener('click', () => { - this.resumeAllDownloads(); - }); - // Modal events document.getElementById('close-confirm').addEventListener('click', () => { this.hideConfirmModal(); @@ -309,14 +297,6 @@ class QueueManager {

${this.escapeHtml(download.serie_name)}

${this.escapeHtml(download.episode.season)}x${String(download.episode.episode).padStart(2, '0')} - ${this.escapeHtml(download.episode.title || 'Episode ' + download.episode.episode)}

-
- - -
@@ -482,7 +462,6 @@ class QueueManager { document.getElementById('start-queue-btn').style.display = 'inline-flex'; } - document.getElementById('pause-all-btn').disabled = !hasActive; document.getElementById('clear-queue-btn').disabled = !hasPending; document.getElementById('retry-all-btn').disabled = !hasFailed; document.getElementById('clear-completed-btn').disabled = !hasCompleted; @@ -688,21 +667,6 @@ class QueueManager { } } - pauseAllDownloads() { - // TODO: Implement pause functionality - this.showToast('Pause functionality not yet implemented', 'info'); - } - - resumeAllDownloads() { - // TODO: Implement resume functionality - this.showToast('Resume functionality not yet implemented', 'info'); - } - - toggleReorderMode() { - // Drag and drop is always enabled, no need for toggle mode - this.showToast('Drag items to reorder the queue', 'info'); - } - initDragAndDrop() { // Initialize drag and drop on the pending queue container const container = document.getElementById('pending-queue'); diff --git a/src/server/web/templates/queue.html b/src/server/web/templates/queue.html index ed37bbe..2890135 100644 --- a/src/server/web/templates/queue.html +++ b/src/server/web/templates/queue.html @@ -106,16 +106,6 @@ Active Downloads -
- - -
diff --git a/tests/integration/test_auth_flow.py b/tests/integration/test_auth_flow.py index c4021e2..fcb9f83 100644 --- a/tests/integration/test_auth_flow.py +++ b/tests/integration/test_auth_flow.py @@ -323,8 +323,8 @@ class TestProtectedEndpoints: endpoints = [ ("/api/queue/status", "GET"), ("/api/queue/add", "POST"), - ("/api/queue/control/start", "POST"), - ("/api/queue/control/pause", "POST"), + ("/api/queue/start", "POST"), + ("/api/queue/pause", "POST"), ] token = await self.get_valid_token(client) diff --git a/tests/integration/test_download_flow.py b/tests/integration/test_download_flow.py index b5f9d29..a525a03 100644 --- a/tests/integration/test_download_flow.py +++ b/tests/integration/test_download_flow.py @@ -216,7 +216,7 @@ class TestQueueControlOperations: async def test_start_queue_processing(self, authenticated_client): """Test starting the queue processor.""" - response = await authenticated_client.post("/api/queue/control/start") + response = await authenticated_client.post("/api/queue/start") assert response.status_code in [200, 503] @@ -227,10 +227,10 @@ class TestQueueControlOperations: async def test_pause_queue_processing(self, authenticated_client): """Test pausing the queue processor.""" # Start first - await authenticated_client.post("/api/queue/control/start") + await authenticated_client.post("/api/queue/start") # Then pause - response = await authenticated_client.post("/api/queue/control/pause") + response = await authenticated_client.post("/api/queue/pause") assert response.status_code in [200, 503] @@ -241,11 +241,11 @@ class TestQueueControlOperations: async def test_resume_queue_processing(self, authenticated_client): """Test resuming the queue processor.""" # Start and pause first - await authenticated_client.post("/api/queue/control/start") - await authenticated_client.post("/api/queue/control/pause") + await authenticated_client.post("/api/queue/start") + await authenticated_client.post("/api/queue/pause") # Then resume - response = await authenticated_client.post("/api/queue/control/resume") + response = await authenticated_client.post("/api/queue/resume") assert response.status_code in [200, 503] @@ -255,7 +255,7 @@ class TestQueueControlOperations: async def test_clear_completed_downloads(self, authenticated_client): """Test clearing completed downloads from the queue.""" - response = await authenticated_client.post("/api/queue/control/clear_completed") + response = await authenticated_client.delete("/api/queue/completed") assert response.status_code in [200, 503] @@ -448,7 +448,7 @@ class TestAuthenticationRequirements: async def test_queue_control_requires_auth(self, client): """Test that queue control endpoints require authentication.""" - response = await client.post("/api/queue/control/start") + response = await client.post("/api/queue/start") assert response.status_code == 401 async def test_item_operations_require_auth(self, client):