From 40302ff75615a0ad0a3bf76f1eaedd7216dcc108 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sat, 29 May 2021 20:37:12 +0200 Subject: [PATCH] Fixed alreadyInQueue not working properly --- package.json | 2 +- server/dist/main.js | 5 +++-- server/package.json | 2 +- server/src/main.ts | 6 +++--- server/yarn.lock | 8 ++++---- yarn.lock | 8 ++++---- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index bf99a16..5096e73 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "cookie-parser": "1.4.5", "debug": "2.6.9", - "deemix": "^0.1.0", + "deemix": "^0.1.1", "deezer-js": "^0.0.10", "dotenv": "8.2.0", "express": "4.17.1", diff --git a/server/dist/main.js b/server/dist/main.js index 290fc38..51be1d2 100644 --- a/server/dist/main.js +++ b/server/dist/main.js @@ -81,12 +81,12 @@ function addToQueue(dz, url, bitrate) { if (url.length > 1) { exports.listener.send("finishGeneratingItems", { uuid: requestUUID, total: downloadObjs.length }); } - const isSingleObject = downloadObjs.length == 1; const slimmedObjects = []; - downloadObjs.forEach((downloadObj) => { + downloadObjs.forEach((downloadObj, pos) => { // Check if element is already in queue if (Object.keys(exports.queue).includes(downloadObj.uuid)) { exports.listener.send('alreadyInQueue', downloadObj.getEssentialDict()); + delete downloadObjs[pos]; return; } // Save queue status when adding something to the queue @@ -101,6 +101,7 @@ function addToQueue(dz, url, bitrate) { fs_1.default.writeFileSync(exports.configFolder + `queue${path_1.sep}${downloadObj.uuid}.json`, JSON.stringify(savedObject)); slimmedObjects.push(downloadObj.getSlimmedDict()); }); + const isSingleObject = downloadObjs.length == 1; if (isSingleObject) exports.listener.send('addedToQueue', downloadObjs[0].getSlimmedDict()); else diff --git a/server/package.json b/server/package.json index 5aa328b..ece5d5f 100644 --- a/server/package.json +++ b/server/package.json @@ -15,7 +15,7 @@ "dependencies": { "cookie-parser": "1.4.5", "debug": "2.6.9", - "deemix": "^0.1.0", + "deemix": "^0.1.1", "deezer-js": "^0.0.10", "dotenv": "8.2.0", "express": "4.17.1", diff --git a/server/src/main.ts b/server/src/main.ts index 898c107..a3b897a 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -76,17 +76,16 @@ export async function addToQueue(dz: any, url: string[], bitrate: number) { listener.send("finishGeneratingItems", {uuid: requestUUID, total: downloadObjs.length}) } - const isSingleObject = downloadObjs.length == 1 const slimmedObjects: any[] = [] - downloadObjs.forEach((downloadObj: any) => { + downloadObjs.forEach((downloadObj: any, pos: number) => { // Check if element is already in queue if (Object.keys(queue).includes(downloadObj.uuid)){ listener.send('alreadyInQueue', downloadObj.getEssentialDict()) + delete downloadObjs[pos] return } - // Save queue status when adding something to the queue if (!fs.existsSync(configFolder + 'queue')) fs.mkdirSync(configFolder + 'queue') @@ -101,6 +100,7 @@ export async function addToQueue(dz: any, url: string[], bitrate: number) { slimmedObjects.push(downloadObj.getSlimmedDict()) }) + const isSingleObject = downloadObjs.length == 1 if (isSingleObject) listener.send('addedToQueue', downloadObjs[0].getSlimmedDict()) else listener.send('addedToQueue', slimmedObjects) diff --git a/server/yarn.lock b/server/yarn.lock index 879605a..9fe99da 100644 --- a/server/yarn.lock +++ b/server/yarn.lock @@ -1883,10 +1883,10 @@ decompress-response@^6.0.0: dependencies: mimic-response "^3.1.0" -deemix@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/deemix/-/deemix-0.1.0.tgz#c66424e55a7a903639dc396ecfc636c55fc6a614" - integrity sha512-z9UC3ShZvTNTj1BmcJTVNxRRdjmZgMzYmrdhT0934dVRefuArcJQRLOcudu8jnYHjTJw2ONnWEIrRGM+3/C/9A== +deemix@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/deemix/-/deemix-0.1.1.tgz#14f7a580cc5a96a2adb9e896b380dba6c4215130" + integrity sha512-vgs3qpCFo3fYh/Vvxi/c0DJ+fJsj6S2LNOUJD7mC40JrEMJW0kLnDuTLr8KLrBakY57rx6eiUUyWIa26p0d1+Q== dependencies: async "^3.2.0" browser-id3-writer "^4.4.0" diff --git a/yarn.lock b/yarn.lock index 45e271c..5d4295b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -813,10 +813,10 @@ decompress-response@^6.0.0: dependencies: mimic-response "^3.1.0" -deemix@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/deemix/-/deemix-0.1.0.tgz#c66424e55a7a903639dc396ecfc636c55fc6a614" - integrity sha512-z9UC3ShZvTNTj1BmcJTVNxRRdjmZgMzYmrdhT0934dVRefuArcJQRLOcudu8jnYHjTJw2ONnWEIrRGM+3/C/9A== +deemix@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/deemix/-/deemix-0.1.1.tgz#14f7a580cc5a96a2adb9e896b380dba6c4215130" + integrity sha512-vgs3qpCFo3fYh/Vvxi/c0DJ+fJsj6S2LNOUJD7mC40JrEMJW0kLnDuTLr8KLrBakY57rx6eiUUyWIa26p0d1+Q== dependencies: async "^3.2.0" browser-id3-writer "^4.4.0"