From 8287ed0aabdf97c988cd644d831564d19a87f7f8 Mon Sep 17 00:00:00 2001 From: Dmitri Date: Thu, 9 Apr 2026 10:36:32 +0400 Subject: [PATCH] debug --- frontend/src/lib/offline/DownloadManager.ts | 36 ++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/offline/DownloadManager.ts b/frontend/src/lib/offline/DownloadManager.ts index 55b68a5..3a409ab 100644 --- a/frontend/src/lib/offline/DownloadManager.ts +++ b/frontend/src/lib/offline/DownloadManager.ts @@ -226,9 +226,21 @@ class DownloadManagerClass { * Process the download queue */ private async processQueue(): Promise { - if (this.isProcessing || this.isPaused) return; + if (this.isProcessing || this.isPaused) { + logger.info('[DownloadManager] processQueue skipped', { + isProcessing: this.isProcessing, + isPaused: this.isPaused, + }); + return; + } if (this.queue.length === 0 && this.activeDownloads.size === 0) return; + logger.info('[DownloadManager] processQueue starting', { + queueLength: this.queue.length, + activeDownloads: this.activeDownloads.size, + maxConcurrent: this.config.maxConcurrent, + }); + this.isProcessing = true; while ( @@ -239,6 +251,11 @@ class DownloadManagerClass { const job = this.queue.shift(); if (!job) break; + logger.info('[DownloadManager] Starting download', { + storageKey: job.storageKey.slice(-50), + url: job.url.slice(0, 80), + }); + this.activeDownloads.set(job.url, job); this.downloadAsset(job); } @@ -272,11 +289,22 @@ class DownloadManagerClass { }); } + logger.info('[DownloadManager] Fetching', { + url: job.url.slice(0, 100), + hasRangeHeader: !!headers['Range'], + }); + const response = await fetch(job.url, { signal: job.abortController.signal, headers, }); + logger.info('[DownloadManager] Fetch response', { + status: response.status, + ok: response.ok, + contentLength: response.headers.get('content-length'), + }); + // Accept both 200 OK and 206 Partial Content if (!response.ok && response.status !== 206) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); @@ -394,6 +422,12 @@ class DownloadManagerClass { await OfflineDbManager.removeFromQueue(job.id); } + logger.info('[DownloadManager] Download complete', { + storageKey: job.storageKey.slice(-50), + bytesLoaded: job.bytesLoaded, + isPartial: job.isPartial, + }); + downloadEventBus.emitPreloadComplete({ jobId: job.id, assetId: job.assetId,