mirror of
https://gitlab.com/RemixDev/deemix-js.git
synced 2024-12-29 10:56:18 +00:00
Fixed queue item not cancelling correctly
This commit is contained in:
parent
03618438af
commit
b57cecb09a
|
@ -167,43 +167,42 @@ class Downloader {
|
||||||
}
|
}
|
||||||
|
|
||||||
async start(){
|
async start(){
|
||||||
if (this.downloadObject.isCanceled){
|
if (!this.downloadObject.isCanceled){
|
||||||
if (this.listener){
|
if (this.downloadObject.__type__ === "Single"){
|
||||||
this.listener.send('currentItemCancelled', this.downloadObject.uuid)
|
let track = await this.downloadWrapper({
|
||||||
this.listener.send("removedFromQueue", this.downloadObject.uuid)
|
trackAPI_gw: this.downloadObject.single.trackAPI_gw,
|
||||||
}
|
trackAPI: this.downloadObject.single.trackAPI,
|
||||||
return
|
albumAPI: this.downloadObject.single.albumAPI
|
||||||
}
|
|
||||||
|
|
||||||
if (this.downloadObject.__type__ === "Single"){
|
|
||||||
let track = await this.downloadWrapper({
|
|
||||||
trackAPI_gw: this.downloadObject.single.trackAPI_gw,
|
|
||||||
trackAPI: this.downloadObject.single.trackAPI,
|
|
||||||
albumAPI: this.downloadObject.single.albumAPI
|
|
||||||
})
|
|
||||||
if (track) await this.afterDownloadSingle(track)
|
|
||||||
} else if (this.downloadObject.__type__ === "Collection") {
|
|
||||||
let tracks = []
|
|
||||||
|
|
||||||
let q = queue(async (data) => {
|
|
||||||
let {track, pos} = data
|
|
||||||
tracks[pos] = await this.downloadWrapper({
|
|
||||||
trackAPI_gw: track,
|
|
||||||
albumAPI: this.downloadObject.collection.albumAPI,
|
|
||||||
playlistAPI: this.downloadObject.collection.playlistAPI
|
|
||||||
})
|
})
|
||||||
}, this.settings.queueConcurrency)
|
if (track) await this.afterDownloadSingle(track)
|
||||||
|
} else if (this.downloadObject.__type__ === "Collection") {
|
||||||
|
let tracks = []
|
||||||
|
|
||||||
this.downloadObject.collection.tracks_gw.forEach((track, pos) => {
|
let q = queue(async (data) => {
|
||||||
q.push({track, pos})
|
let {track, pos} = data
|
||||||
})
|
tracks[pos] = await this.downloadWrapper({
|
||||||
|
trackAPI_gw: track,
|
||||||
|
albumAPI: this.downloadObject.collection.albumAPI,
|
||||||
|
playlistAPI: this.downloadObject.collection.playlistAPI
|
||||||
|
})
|
||||||
|
}, this.settings.queueConcurrency)
|
||||||
|
|
||||||
await q.drain()
|
this.downloadObject.collection.tracks_gw.forEach((track, pos) => {
|
||||||
await this.afterDownloadCollection(tracks)
|
q.push({track, pos})
|
||||||
|
})
|
||||||
|
|
||||||
|
await q.drain()
|
||||||
|
await this.afterDownloadCollection(tracks)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.listener){
|
if (this.listener){
|
||||||
this.listener.send("finishDownload", this.downloadObject.uuid)
|
if (this.downloadObject.isCanceled){
|
||||||
|
this.listener.send('currentItemCancelled', this.downloadObject.uuid)
|
||||||
|
this.listener.send("removedFromQueue", this.downloadObject.uuid)
|
||||||
|
} else {
|
||||||
|
this.listener.send("finishDownload", this.downloadObject.uuid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue