refactor: replace upgrader with version package for runtime and release information

This commit is contained in:
Jacky 2025-04-21 08:06:27 +00:00
parent 8e212ae79b
commit d0cf93d5e3
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
11 changed files with 182 additions and 121 deletions

View file

@ -3,13 +3,6 @@ package upgrader
import (
"encoding/json"
"fmt"
_github "github.com/0xJacky/Nginx-UI/.github"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/jpillora/overseer"
"github.com/minio/selfupdate"
"github.com/pkg/errors"
"github.com/uozi-tech/cosy/logger"
"io"
"net/http"
"net/url"
@ -18,19 +11,40 @@ import (
"strconv"
"strings"
"sync/atomic"
_github "github.com/0xJacky/Nginx-UI/.github"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/version"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/jpillora/overseer"
"github.com/minio/selfupdate"
"github.com/pkg/errors"
"github.com/uozi-tech/cosy/logger"
)
const (
UpgradeStatusInfo = "info"
UpgradeStatusError = "error"
UpgradeStatusProgress = "progress"
)
type CoreUpgradeResp struct {
Status string `json:"status"`
Progress float64 `json:"progress"`
Message string `json:"message"`
}
type Upgrader struct {
Release TRelease
RuntimeInfo
Release version.TRelease
version.RuntimeInfo
}
func NewUpgrader(channel string) (u *Upgrader, err error) {
data, err := GetRelease(channel)
data, err := version.GetRelease(channel)
if err != nil {
return
}
runtimeInfo, err := GetRuntimeInfo()
runtimeInfo, err := version.GetRuntimeInfo()
if err != nil {
return
}