From 1a590fc6be45838b212d60f188330c7f5d5157b0 Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Mon, 2 Nov 2026 15:25:12 -0700 Subject: [PATCH] refactor(api): tidy leftovers from the api perf pass Use the service_name local in handle_single_server_cdm, assign service_data once in /api/services, and keep the TERMINAL_STATUSES comment on its constant. --- unshackle/core/api/download_manager.py | 2 +- unshackle/core/api/handlers.py | 4 ++-- unshackle/core/api/routes.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/unshackle/core/api/download_manager.py b/unshackle/core/api/download_manager.py index c02a2b4d..ccba9957 100644 --- a/unshackle/core/api/download_manager.py +++ b/unshackle/core/api/download_manager.py @@ -92,8 +92,8 @@ class JobStatus(Enum): CANCELLED = "cancelled" -# Statuses a job can never leave; such jobs are safe to remove or retry. WORKER_STDERR_LIMIT = 64 * 1024 +# Statuses a job can never leave; such jobs are safe to remove or retry. TERMINAL_STATUSES = (JobStatus.COMPLETED, JobStatus.FAILED, JobStatus.CANCELLED) diff --git a/unshackle/core/api/handlers.py b/unshackle/core/api/handlers.py index 649984d4..3c5158bc 100644 --- a/unshackle/core/api/handlers.py +++ b/unshackle/core/api/handlers.py @@ -5139,7 +5139,7 @@ def handle_single_server_cdm( pr_drm.absorb(*siblings) # Gate on the caller's CDM device first: no device, no keys from the vault or CDM. - device_name = resolve_device_name(user_config, drm_type, service.__class__.__name__) + device_name = resolve_device_name(user_config, drm_type, service_name) if refusal: raise refusal @@ -5166,7 +5166,7 @@ def handle_single_server_cdm( # Gate on the caller's CDM device first so a caller with no device cannot # harvest server-side keys from the vault fallback below. - device_name = resolve_device_name(user_config, drm_type, service.__class__.__name__) + device_name = resolve_device_name(user_config, drm_type, service_name) vault_hit = check_vaults(wv_drm.kids, service_name, shared=shared) if vault_hit: diff --git a/unshackle/core/api/routes.py b/unshackle/core/api/routes.py index 5d35fd98..a8b36d16 100644 --- a/unshackle/core/api/routes.py +++ b/unshackle/core/api/routes.py @@ -515,11 +515,11 @@ async def services(request: web.Request) -> web.Response: services_info = [] for tag in service_tags: - service_data: dict[str, Any] = {**SERVICE_DEFAULTS, "tag": tag} try: - service_data = {**service_details(tag)} + service_data: dict[str, Any] = {**service_details(tag)} except Exception as e: log.warning(f"Could not load details for service {tag}: {e}") + service_data = {**SERVICE_DEFAULTS, "tag": tag} if tag in services_module.PENDING: service_data["pending_update"] = True if server_accounts_allowed(request, tag) and (server_accounts := server_account_regions(tag)) is not None: