finished: check update
This commit is contained in:
@@ -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))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user