From 5291cbbd16dff6303414759d37239324f11cd2b3 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sat, 29 May 2021 16:21:00 +0200 Subject: [PATCH] Fixed artist download issue --- server/dist/main.js | 8 +++++--- server/dist/routes/api/post/addToQueue.js | 4 ---- server/src/main.ts | 9 ++++++--- server/src/routes/api/post/addToQueue.ts | 4 ---- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/server/dist/main.js b/server/dist/main.js index 12c90c4..290fc38 100644 --- a/server/dist/main.js +++ b/server/dist/main.js @@ -72,7 +72,7 @@ function addToQueue(dz, url, bitrate) { console.log(`Adding ${link} to queue`); let downloadObj = yield deemix_1.default.generateDownloadObject(dz, link, bitrate, exports.plugins, exports.listener); if (Array.isArray(downloadObj)) { - downloadObjs.concat(downloadObj); + downloadObjs = downloadObjs.concat(downloadObj); } else { downloadObjs.push(downloadObj); @@ -85,8 +85,10 @@ function addToQueue(dz, url, bitrate) { const slimmedObjects = []; downloadObjs.forEach((downloadObj) => { // Check if element is already in queue - if (Object.keys(exports.queue).includes(downloadObj.uuid)) - throw new errors_1.AlreadyInQueue(downloadObj.getEssentialDict(), !isSingleObject); + if (Object.keys(exports.queue).includes(downloadObj.uuid)) { + exports.listener.send('alreadyInQueue', downloadObj.getEssentialDict()); + return; + } // Save queue status when adding something to the queue if (!fs_1.default.existsSync(exports.configFolder + 'queue')) fs_1.default.mkdirSync(exports.configFolder + 'queue'); diff --git a/server/dist/routes/api/post/addToQueue.js b/server/dist/routes/api/post/addToQueue.js index d649fd5..2d8f7e8 100644 --- a/server/dist/routes/api/post/addToQueue.js +++ b/server/dist/routes/api/post/addToQueue.js @@ -27,10 +27,6 @@ const handler = (req, res) => __awaiter(void 0, void 0, void 0, function* () { } catch (e) { switch (e.name) { - case 'AlreadyInQueue': - res.send({ result: false, errid: e.name, data: { url, bitrate, obj: e.item } }); - main_1.listener.send('alreadyInQueue', e.item); - break; case 'NotLoggedIn': res.send({ result: false, errid: e.name, data: { url, bitrate } }); main_1.listener.send('loginNeededToDownload'); diff --git a/server/src/main.ts b/server/src/main.ts index e2fb289..898c107 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -66,7 +66,7 @@ export async function addToQueue(dz: any, url: string[], bitrate: number) { console.log(`Adding ${link} to queue`) let downloadObj = await deemix.generateDownloadObject(dz, link, bitrate, plugins, listener) if (Array.isArray(downloadObj)){ - downloadObjs.concat(downloadObj) + downloadObjs = downloadObjs.concat(downloadObj) } else { downloadObjs.push(downloadObj) } @@ -81,8 +81,11 @@ export async function addToQueue(dz: any, url: string[], bitrate: number) { downloadObjs.forEach((downloadObj: any) => { // Check if element is already in queue - if (Object.keys(queue).includes(downloadObj.uuid)) - throw new AlreadyInQueue(downloadObj.getEssentialDict(), !isSingleObject) + if (Object.keys(queue).includes(downloadObj.uuid)){ + listener.send('alreadyInQueue', downloadObj.getEssentialDict()) + return + } + // Save queue status when adding something to the queue if (!fs.existsSync(configFolder + 'queue')) fs.mkdirSync(configFolder + 'queue') diff --git a/server/src/routes/api/post/addToQueue.ts b/server/src/routes/api/post/addToQueue.ts index f7c271b..1db5f77 100644 --- a/server/src/routes/api/post/addToQueue.ts +++ b/server/src/routes/api/post/addToQueue.ts @@ -18,10 +18,6 @@ const handler: ApiHandler['handler'] = async (req, res) => { obj = await addToQueue(dz, url, bitrate) } catch (e) { switch (e.name) { - case 'AlreadyInQueue': - res.send({ result: false, errid: e.name, data: { url, bitrate, obj: e.item } }) - listener.send('alreadyInQueue', e.item) - break case 'NotLoggedIn': res.send({ result: false, errid: e.name, data: { url, bitrate } }) listener.send('loginNeededToDownload')