Fix downloaded size being incorrectly reported

This commit is contained in:
Xpl0itU 2024-04-16 15:26:43 +02:00
parent e5c555c2a7
commit a6ccbb2473
2 changed files with 5 additions and 3 deletions

View file

@ -128,8 +128,10 @@ func (pw *ProgressWindow) SetDownloadSize(size int64) {
pw.totalToDownload = size pw.totalToDownload = size
} }
func (pw *ProgressWindow) ResetTotalDownloaded() { func (pw *ProgressWindow) ResetTotals() {
pw.progressPerFile = make(map[string]int64) pw.progressPerFile = make(map[string]int64)
pw.totalDownloaded = 0
pw.totalToDownload = 0
} }
func (pw *ProgressWindow) MarkFileAsDone(filename string) { func (pw *ProgressWindow) MarkFileAsDone(filename string) {

View file

@ -35,7 +35,7 @@ type ProgressReporter interface {
Cancelled() bool Cancelled() bool
SetCancelled() SetCancelled()
SetDownloadSize(size int64) SetDownloadSize(size int64)
ResetTotalDownloaded() ResetTotals()
MarkFileAsDone(filename string) MarkFileAsDone(filename string)
SetTotalDownloadedForFile(filename string, downloaded int64) SetTotalDownloadedForFile(filename string, downloaded int64)
SetStartTime(startTime time.Time) SetStartTime(startTime time.Time)
@ -161,7 +161,7 @@ func downloadFile(progressReporter ProgressReporter, client *http.Client, downlo
func DownloadTitle(titleID, outputDirectory string, doDecryption bool, progressReporter ProgressReporter, deleteEncryptedContents bool, client *http.Client) error { func DownloadTitle(titleID, outputDirectory string, doDecryption bool, progressReporter ProgressReporter, deleteEncryptedContents bool, client *http.Client) error {
tEntry := getTitleEntryFromTid(titleID) tEntry := getTitleEntryFromTid(titleID)
progressReporter.ResetTotalDownloaded() progressReporter.ResetTotals()
progressReporter.SetGameTitle(tEntry.Name) progressReporter.SetGameTitle(tEntry.Name)
outputDir := strings.TrimRight(outputDirectory, "/\\") outputDir := strings.TrimRight(outputDirectory, "/\\")