mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15: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
|
@ -38,9 +38,9 @@ onMounted(() => {
|
||||||
<div>
|
<div>
|
||||||
{{ item.description?.() }}
|
{{ item.description?.() }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="item.status !== 'success'" class="mt-1">
|
<div v-if="item.status !== 'success' && item.err?.message" class="mt-1">
|
||||||
<ATag :color="item.status === 'warning' ? 'warning' : 'error'">
|
<ATag :color="item.status === 'warning' ? 'warning' : 'error'">
|
||||||
{{ item.err?.message || $gettext('Unknown issue') }}
|
{{ $gettext(item.err?.message) }}
|
||||||
</ATag>
|
</ATag>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -3,7 +3,6 @@ package upgrader
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"code.pfad.fr/risefront"
|
|
||||||
"github.com/0xJacky/Nginx-UI/settings"
|
"github.com/0xJacky/Nginx-UI/settings"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/uozi-tech/cosy/logger"
|
"github.com/uozi-tech/cosy/logger"
|
||||||
|
@ -71,9 +70,8 @@ func BinaryUpgrade(ws *websocket.Conn, control *Control) {
|
||||||
Status: UpgradeStatusInfo,
|
Status: UpgradeStatusInfo,
|
||||||
Message: "Performing core upgrade",
|
Message: "Performing core upgrade",
|
||||||
})
|
})
|
||||||
// dry run
|
|
||||||
if control.DryRun || settings.NodeSettings.Demo {
|
if settings.NodeSettings.Demo {
|
||||||
risefront.Restart()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -217,8 +218,10 @@ func (u *Upgrader) PerformCoreUpgrade(tarPath string) (err error) {
|
||||||
}
|
}
|
||||||
defer updateInProgress.Store(false)
|
defer updateInProgress.Store(false)
|
||||||
|
|
||||||
|
oldExe := filepath.Join(filepath.Dir(u.ExPath), ".nginx-ui.old."+strconv.FormatInt(time.Now().Unix(), 10))
|
||||||
|
|
||||||
opts := selfupdate.Options{
|
opts := selfupdate.Options{
|
||||||
OldSavePath: fmt.Sprintf(".nginx-ui.old.%d", time.Now().Unix()),
|
OldSavePath: oldExe,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = opts.CheckPermissions(); err != nil {
|
if err = opts.CheckPermissions(); err != nil {
|
||||||
|
@ -269,6 +272,10 @@ func (u *Upgrader) PerformCoreUpgrade(tarPath string) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
|
_ = os.Remove(oldExe)
|
||||||
|
}
|
||||||
|
|
||||||
// wait for the file to be written
|
// wait for the file to be written
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue