mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 14:19:38 +00:00
Fixed download bugs
This commit is contained in:
@@ -29,9 +29,11 @@ export class StatusBarComponent {
|
|||||||
ref: ChangeDetectorRef
|
ref: ChangeDetectorRef
|
||||||
) {
|
) {
|
||||||
downloadService.onDownloadUpdated(() => {
|
downloadService.onDownloadUpdated(() => {
|
||||||
|
setTimeout(() => { // Make sure this is the last callback executed to get the accurate downloadCount
|
||||||
this.downloading = downloadService.downloadCount > 0
|
this.downloading = downloadService.downloadCount > 0
|
||||||
this.percent = downloadService.totalPercent
|
this.percent = downloadService.totalPercent
|
||||||
ref.detectChanges()
|
ref.detectChanges()
|
||||||
|
}, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
searchService.onSearchChanged(() => {
|
searchService.onSearchChanged(() => {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export class DownloadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onDownloadUpdated(callback: (download: DownloadProgress) => void) {
|
onDownloadUpdated(callback: (download: DownloadProgress) => void) {
|
||||||
const debouncedCallback = _.throttle(callback, 30)
|
const debouncedCallback = _.throttle(callback, 30, { trailing: false })
|
||||||
this.downloadUpdatedEmitter.subscribe((download: DownloadProgress) => {
|
this.downloadUpdatedEmitter.subscribe((download: DownloadProgress) => {
|
||||||
if (download.type == 'fastUpdate') { // 'good' updates can happen so frequently that the UI doesn't update correctly
|
if (download.type == 'fastUpdate') { // 'good' updates can happen so frequently that the UI doesn't update correctly
|
||||||
debouncedCallback(download)
|
debouncedCallback(download)
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export class ChartDownload {
|
|||||||
|
|
||||||
// DOWNLOAD FILES
|
// DOWNLOAD FILES
|
||||||
for (let i = 0; i < this.files.length; i++) {
|
for (let i = 0; i < this.files.length; i++) {
|
||||||
const downloader = new FileDownloader(this.files[i].webContentLink, chartPath)
|
const downloader = new FileDownloader(this.files[i].webContentLink, join(chartPath, this.files[i].name))
|
||||||
this.cancelFn = () => downloader.cancelDownload()
|
this.cancelFn = () => downloader.cancelDownload()
|
||||||
|
|
||||||
const downloadComplete = this.addDownloadEventListeners(downloader, i)
|
const downloadComplete = this.addDownloadEventListeners(downloader, i)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class DownloadHandler implements IPCEmitHandler<'download'> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private retryDownload(data: Download) {
|
private retryDownload(data: Download) { // TODO: cause this to send a GUI update that says waiting for download to finish...
|
||||||
const index = this.retryWaiting.findIndex(download => download.versionID == data.versionID)
|
const index = this.retryWaiting.findIndex(download => download.versionID == data.versionID)
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
const retryDownload = this.retryWaiting.splice(index, 1)[0]
|
const retryDownload = this.retryWaiting.splice(index, 1)[0]
|
||||||
@@ -43,7 +43,7 @@ class DownloadHandler implements IPCEmitHandler<'download'> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private cancelDownload(data: Download) {
|
private cancelDownload(data: Download) {
|
||||||
if (this.currentDownload.versionID == data.versionID) {
|
if (this.currentDownload?.versionID == data.versionID) {
|
||||||
this.currentDownload.cancel()
|
this.currentDownload.cancel()
|
||||||
this.currentDownload = undefined
|
this.currentDownload = undefined
|
||||||
this.startNextDownload()
|
this.startNextDownload()
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export class FileExtractor {
|
|||||||
const stream = node7z.extractFull(fullPath, this.sourceFolder, { $progress: true, $bin: zipBin.path7za })
|
const stream = node7z.extractFull(fullPath, this.sourceFolder, { $progress: true, $bin: zipBin.path7za })
|
||||||
|
|
||||||
stream.on('progress', this.cancelable((progress: { percent: number; fileCount: number }) => {
|
stream.on('progress', this.cancelable((progress: { percent: number; fileCount: number }) => {
|
||||||
this.callbacks.extractProgress(progress.percent, progress.fileCount)
|
this.callbacks.extractProgress(progress.percent, isNaN(progress.fileCount) ? 0 : progress.fileCount)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
let extractErrorOccured = false
|
let extractErrorOccured = false
|
||||||
|
|||||||
Reference in New Issue
Block a user