mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 14:19:38 +00:00
Prevent multiple downloads of the same thing
This commit is contained in:
@@ -41,6 +41,7 @@ export class ChartDownload {
|
||||
/** If this chart download needs to be retried */
|
||||
get hasFailed() { return this._hasFailed }
|
||||
get isArchive() { return this.data.driveData.isArchive }
|
||||
get hash() { return this.data.driveData.filesHash }
|
||||
|
||||
constructor(public versionID: number, private data: NewDownload) {
|
||||
this.updateGUI('', 'Waiting for other downloads to finish...', 'good')
|
||||
|
||||
@@ -19,6 +19,11 @@ class DownloadHandler implements IPCEmitHandler<'download'> {
|
||||
}
|
||||
|
||||
private addDownload(data: Download) {
|
||||
const filesHash = data.data.driveData.filesHash
|
||||
if (this.currentDownload?.hash == filesHash || this.downloadQueue.isDownloadingLink(filesHash)) {
|
||||
return
|
||||
}
|
||||
|
||||
const newDownload = new ChartDownload(data.versionID, data.data)
|
||||
this.addDownloadEventListeners(newDownload)
|
||||
if (this.currentDownload == undefined) {
|
||||
|
||||
@@ -6,6 +6,10 @@ export class DownloadQueue {
|
||||
|
||||
downloadQueue: ChartDownload[] = []
|
||||
|
||||
isDownloadingLink(filesHash: string) {
|
||||
return this.downloadQueue.some(download => download.hash == filesHash)
|
||||
}
|
||||
|
||||
isEmpty() {
|
||||
return this.downloadQueue.length == 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user