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