This commit is contained in:
josc146
2023-05-17 23:27:52 +08:00
parent df8eef5f64
commit 00257f2e68
15 changed files with 160 additions and 35 deletions

View File

@@ -2,6 +2,9 @@ package backend_golang
import (
"context"
"net/http"
"github.com/minio/selfupdate"
)
// App struct
@@ -19,3 +22,19 @@ func NewApp() *App {
func (a *App) OnStartup(ctx context.Context) {
a.ctx = ctx
}
func (a *App) UpdateApp(url string) (broken bool, err error) {
resp, err := http.Get(url)
if err != nil {
return false, err
}
defer resp.Body.Close()
err = selfupdate.Apply(resp.Body, selfupdate.Options{})
if err != nil {
if rerr := selfupdate.RollbackError(err); rerr != nil {
return true, rerr
}
return false, err
}
return false, nil
}