finished: check update

This commit is contained in:
2024-07-23 16:32:49 +08:00
parent b7d64cba7b
commit e0dbd03397
16 changed files with 511 additions and 37 deletions
+22
View File
@@ -1,7 +1,12 @@
package main
import (
"MacFastLookup/service"
"context"
"os"
"path/filepath"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
// App struct
@@ -19,3 +24,20 @@ func NewApp() *App {
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
}
func (a *App) StartDownload() {
dbFileDir := ".macfastlookup"
userHomeDir, _ := os.UserHomeDir()
dbFileName := "mac_vendors.sqlite3"
dbFilePath := filepath.Join(userHomeDir, dbFileDir, dbFileName)
// create the folder if not exist
path := filepath.Join(userHomeDir, dbFileDir)
if _, err := os.Stat(path); os.IsNotExist(err) {
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))
})
}