debug
This commit is contained in:
parent
ef137199ec
commit
8287ed0aab
@ -226,9 +226,21 @@ class DownloadManagerClass {
|
|||||||
* Process the download queue
|
* Process the download queue
|
||||||
*/
|
*/
|
||||||
private async processQueue(): Promise<void> {
|
private async processQueue(): Promise<void> {
|
||||||
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;
|
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;
|
this.isProcessing = true;
|
||||||
|
|
||||||
while (
|
while (
|
||||||
@ -239,6 +251,11 @@ class DownloadManagerClass {
|
|||||||
const job = this.queue.shift();
|
const job = this.queue.shift();
|
||||||
if (!job) break;
|
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.activeDownloads.set(job.url, job);
|
||||||
this.downloadAsset(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, {
|
const response = await fetch(job.url, {
|
||||||
signal: job.abortController.signal,
|
signal: job.abortController.signal,
|
||||||
headers,
|
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
|
// Accept both 200 OK and 206 Partial Content
|
||||||
if (!response.ok && response.status !== 206) {
|
if (!response.ok && response.status !== 206) {
|
||||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||||
@ -394,6 +422,12 @@ class DownloadManagerClass {
|
|||||||
await OfflineDbManager.removeFromQueue(job.id);
|
await OfflineDbManager.removeFromQueue(job.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info('[DownloadManager] Download complete', {
|
||||||
|
storageKey: job.storageKey.slice(-50),
|
||||||
|
bytesLoaded: job.bytesLoaded,
|
||||||
|
isPartial: job.isPartial,
|
||||||
|
});
|
||||||
|
|
||||||
downloadEventBus.emitPreloadComplete({
|
downloadEventBus.emitPreloadComplete({
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
assetId: job.assetId,
|
assetId: job.assetId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user