diff --git a/package.json b/package.json index eb3447c..10a5481 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "floatplane-plex-downloader", - "version": "5.12.2", + "version": "5.13.0", "private": true, "type": "module", "scripts": { @@ -53,4 +53,4 @@ "pkg": "^5.8.1", "typescript": "^5.4.3" } -} +} \ No newline at end of file diff --git a/src/lib/VideoBase.ts b/src/lib/VideoBase.ts index ed905af..c6ee2a8 100644 --- a/src/lib/VideoBase.ts +++ b/src/lib/VideoBase.ts @@ -140,7 +140,7 @@ export class VideoBase extends Attachment { } = await fApi.cdn.delivery("download", this.attachmentId); // Release the semaphore after DeliveryTimeout - setTimeout(VideoBase.DeliverySemaphore.release, VideoBase.DeliveryTimeout); + setTimeout(() => VideoBase.DeliverySemaphore.release(), VideoBase.DeliveryTimeout); return delivery; } diff --git a/src/lib/helpers/Semaphore.ts b/src/lib/helpers/Semaphore.ts index ef728e7..4561f14 100644 --- a/src/lib/helpers/Semaphore.ts +++ b/src/lib/helpers/Semaphore.ts @@ -1,10 +1,9 @@ export class Semaphore { private avalibleSlots: number; - private readonly _queue: (() => void)[]; + private readonly queued: (() => void)[] = []; constructor(slots: number) { this.avalibleSlots = slots; - this._queue = []; } public async obtain() { @@ -12,12 +11,12 @@ export class Semaphore { if (this.avalibleSlots > 0) return this.avalibleSlots--; // Otherwise, wait for a request slot to become available - return new Promise((r) => this._queue.push(() => r(this.avalibleSlots--))); + return new Promise((r) => this.queued.push(() => r(this.avalibleSlots--))); } public release(): void { this.avalibleSlots++; // If there are queued requests, resolve the first one in the queue - this._queue.shift()?.(); + this.queued.shift()?.(); } } diff --git a/src/lib/helpers/index.ts b/src/lib/helpers/index.ts index b9d229c..8ec05df 100644 --- a/src/lib/helpers/index.ts +++ b/src/lib/helpers/index.ts @@ -13,7 +13,7 @@ import "dotenv/config"; import json5 from "json5"; const { parse } = json5; -export const DownloaderVersion = "5.12.2"; +export const DownloaderVersion = "5.13.0"; import type { PartialArgs, Settings } from "../types.js";