mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-10 18:05:48 +02:00
fix(SelfCheck): improve error message handling and update upgrade logic
This commit is contained in:
parent
8bbb2ff559
commit
9f6f9088c4
3 changed files with 12 additions and 7 deletions
|
@ -3,7 +3,6 @@ package upgrader
|
|||
import (
|
||||
"os"
|
||||
|
||||
"code.pfad.fr/risefront"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
|
@ -71,9 +70,8 @@ func BinaryUpgrade(ws *websocket.Conn, control *Control) {
|
|||
Status: UpgradeStatusInfo,
|
||||
Message: "Performing core upgrade",
|
||||
})
|
||||
// dry run
|
||||
if control.DryRun || settings.NodeSettings.Demo {
|
||||
risefront.Restart()
|
||||
|
||||
if settings.NodeSettings.Demo {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
@ -217,8 +218,10 @@ func (u *Upgrader) PerformCoreUpgrade(tarPath string) (err error) {
|
|||
}
|
||||
defer updateInProgress.Store(false)
|
||||
|
||||
oldExe := filepath.Join(filepath.Dir(u.ExPath), ".nginx-ui.old."+strconv.FormatInt(time.Now().Unix(), 10))
|
||||
|
||||
opts := selfupdate.Options{
|
||||
OldSavePath: fmt.Sprintf(".nginx-ui.old.%d", time.Now().Unix()),
|
||||
OldSavePath: oldExe,
|
||||
}
|
||||
|
||||
if err = opts.CheckPermissions(); err != nil {
|
||||
|
@ -269,6 +272,10 @@ func (u *Upgrader) PerformCoreUpgrade(tarPath string) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
if runtime.GOOS != "windows" {
|
||||
_ = os.Remove(oldExe)
|
||||
}
|
||||
|
||||
// wait for the file to be written
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue