From 9f6f9088c49ca92409b57dbbca528b3d3d4b9e87 Mon Sep 17 00:00:00 2001 From: Jacky Date: Mon, 5 May 2025 11:57:59 +0000 Subject: [PATCH] fix(SelfCheck): improve error message handling and update upgrade logic --- app/src/components/SelfCheck/SelfCheck.vue | 4 ++-- internal/upgrader/binary.go | 6 ++---- internal/upgrader/upgrade.go | 9 ++++++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/components/SelfCheck/SelfCheck.vue b/app/src/components/SelfCheck/SelfCheck.vue index d3a58212..68593497 100644 --- a/app/src/components/SelfCheck/SelfCheck.vue +++ b/app/src/components/SelfCheck/SelfCheck.vue @@ -38,9 +38,9 @@ onMounted(() => {
{{ item.description?.() }}
-
+
- {{ item.err?.message || $gettext('Unknown issue') }} + {{ $gettext(item.err?.message) }}
diff --git a/internal/upgrader/binary.go b/internal/upgrader/binary.go index 0cdeeffc..bfb45a53 100644 --- a/internal/upgrader/binary.go +++ b/internal/upgrader/binary.go @@ -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 } diff --git a/internal/upgrader/upgrade.go b/internal/upgrader/upgrade.go index da1eb553..dd3754c7 100644 --- a/internal/upgrader/upgrade.go +++ b/internal/upgrader/upgrade.go @@ -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)