enhanced: download progress

This commit is contained in:
2024-07-25 10:06:09 +08:00
parent 97b18d8c5c
commit 7380574143
3 changed files with 79 additions and 76 deletions
+4 -2
View File
@@ -3,6 +3,7 @@ package main
import (
"MacFastLookup/service"
"context"
"fmt"
"os"
"path/filepath"
@@ -37,7 +38,8 @@ func (a *App) StartDownload() {
os.Mkdir(path, 0755)
}
service.DownloadFile("https://tools.taurusxin.com/macfastlookup/mac_vendors.sqlite3", dbFilePath, true, func(progress, total int64) {
runtime.EventsEmit(a.ctx, "download-progress", float32(progress / total))
service.EnhancedDownload("https://tools.taurusxin.com/macfastlookup/mac_vendors.sqlite3", dbFilePath, true, func(downloaded, total, rate int64, packageName string) {
fmt.Printf("\rDownloading[%s][ %d%% ][%d/%d]", packageName, rate, downloaded, total)
runtime.EventsEmit(a.ctx, "download-progress", rate)
})
}