Skip to content

Commit 1fcf359

Browse files
author
ssongliu
committed
fix: Fix the exception of some 1pctl commands
1 parent d09a3d8 commit 1fcf359

25 files changed

Lines changed: 70 additions & 35 deletions

File tree

agent/app/service/backup_record.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,14 @@ func (u *BackupRecordService) ListAppRecords(name, detailName, fileName string)
177177

178178
func (u *BackupRecordService) ListFiles(req dto.OperateByID) []string {
179179
var datas []string
180-
_, client, err := NewBackupClientWithID(req.ID)
180+
backupItem, client, err := NewBackupClientWithID(req.ID)
181181
if err != nil {
182182
return datas
183183
}
184184
prefix := "system_snapshot"
185+
if len(backupItem.BackupPath) != 0 {
186+
prefix = path.Join(backupItem.BackupPath, prefix)
187+
}
185188
files, err := client.ListObjects(prefix)
186189
if err != nil {
187190
global.LOG.Debugf("load files failed, err: %v", err)

agent/utils/cloud_storage/client/up.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (o upClient) ListBuckets() ([]interface{}, error) {
3131

3232
func (s upClient) Upload(src, target string) (bool, error) {
3333
if _, err := s.client.GetInfo(path.Dir(src)); err != nil {
34-
_ = s.client.Mkdir(path.Dir(src))
34+
_ = s.client.Mkdir(path.Dir(target))
3535
}
3636
if err := s.client.Put(&upyun.PutObjectConfig{
3737
Path: target,

core/app/service/upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (u *UpgradeService) Upgrade(req dto.Upgrade) error {
130130
_ = settingRepo.Update("SystemStatus", "Free")
131131
return
132132
}
133-
itemLog := model.UpgradeLog{NodeID: 0, OldVersion: global.CONF.Base.Version, NewVersion: req.Version, BackupFile: originalDir}
133+
itemLog := model.UpgradeLog{NodeID: 0, OldVersion: global.CONF.Base.Version, NewVersion: req.Version, BackupFile: baseDir}
134134
_ = upgradeLogRepo.Create(&itemLog)
135135

136136
global.LOG.Info("backup original data successful, now start to upgrade!")

core/cmd/server/cmd/listen-ip.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"fmt"
55

6+
"github.com/1Panel-dev/1Panel/core/constant"
67
"github.com/1Panel-dev/1Panel/core/i18n"
78
"github.com/spf13/cobra"
89
)
@@ -51,11 +52,11 @@ func updateBindInfo(protocol string) error {
5152
if err != nil {
5253
return err
5354
}
54-
ipv6 := "disable"
55+
ipv6 := constant.StatusDisable
5556
tcp := "tcp4"
5657
address := "0.0.0.0"
5758
if protocol == "ipv6" {
58-
ipv6 = "enable"
59+
ipv6 = constant.StatusEnable
5960
tcp = "tcp6"
6061
address = "::"
6162
}

core/cmd/server/cmd/reset.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"fmt"
55

6+
"github.com/1Panel-dev/1Panel/core/constant"
67
"github.com/1Panel-dev/1Panel/core/i18n"
78
"github.com/spf13/cobra"
89
)
@@ -43,7 +44,7 @@ var resetMFACmd = &cobra.Command{
4344
return err
4445
}
4546

46-
return setSettingByKey(db, "MFAStatus", "disable")
47+
return setSettingByKey(db, "MFAStatus", constant.StatusDisable)
4748
},
4849
}
4950
var resetSSLCmd = &cobra.Command{
@@ -59,7 +60,7 @@ var resetSSLCmd = &cobra.Command{
5960
return err
6061
}
6162

62-
return setSettingByKey(db, "SSL", "disable")
63+
return setSettingByKey(db, "SSL", constant.StatusDisable)
6364
},
6465
}
6566
var resetEntranceCmd = &cobra.Command{

core/cmd/server/cmd/restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ var restoreCmd = &cobra.Command{
7373
}
7474
fmt.Println(i18n.GetMsgByKeyForCmd("RestoreStep4"))
7575
if _, err := os.Stat(path.Join(tmpPath, "db")); err == nil {
76-
dbPath := path.Join(baseDir, "1panel/db")
76+
dbPath := path.Join(baseDir, "1panel")
7777
if err := files.CopyItem(true, true, path.Join(tmpPath, "db"), dbPath); err != nil {
7878
global.LOG.Errorf("rollback 1panel db failed, err: %v", err)
7979
}

core/cmd/server/cmd/update.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010
"unicode"
1111

12+
"github.com/1Panel-dev/1Panel/core/constant"
1213
"github.com/1Panel-dev/1Panel/core/global"
1314
"github.com/1Panel-dev/1Panel/core/i18n"
1415
"github.com/1Panel-dev/1Panel/core/utils/cmd"
@@ -136,7 +137,7 @@ func password() {
136137
return
137138
}
138139
complexSetting := getSettingByKey(db, "ComplexityVerification")
139-
if complexSetting == "enable" {
140+
if complexSetting == constant.StatusEnable {
140141
if isValidPassword("newPassword") {
141142
fmt.Println("\n" + i18n.GetMsgByKeyForCmd("UpdatePasswordFormat"))
142143
return

core/cmd/server/cmd/user-info.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"fmt"
55

6+
"github.com/1Panel-dev/1Panel/core/constant"
67
"github.com/1Panel-dev/1Panel/core/global"
78
"github.com/1Panel-dev/1Panel/core/i18n"
89
"github.com/1Panel-dev/1Panel/core/utils/encrypt"
@@ -41,7 +42,7 @@ var userinfoCmd = &cobra.Command{
4142
address := getSettingByKey(db, "SystemIP")
4243

4344
protocol := "http"
44-
if ssl == "enable" {
45+
if ssl == constant.StatusEnable {
4546
protocol = "https"
4647
}
4748
if address == "" {

core/i18n/lang/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ ErrNodeBoundLimit: "The current free node has reached its limit, please check an
6262
ErrNoSuchNode: "Node information not found, please check and retry!"
6363
ErrNodeUnbind: "This node is not within the license binding range, please check and retry!"
6464
ErrNodeBind: "This node is already bound to a license, please check and retry!"
65+
ErrNodeLocalRollback: "The primary node does not support direct rollback. Please manually execute the '1pctl restore' command to rollback!"
6566

6667
# alert
6768
ErrAlertSync: "Alert information sync error, please check and retry!"

core/i18n/lang/ja.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ ErrNodeBoundLimit: "現在の無料ノードは上限に達しました。確認
6363
ErrNoSuchNode: "そのノード情報が見つかりませんでした、確認して再試行してください!"
6464
ErrNodeUnbind: "そのノードはライセンスのバインド範囲内ではありません、確認して再試行してください!"
6565
ErrNodeBind: "そのノードはライセンスにバインドされています、確認して再試行してください!"
66+
ErrNodeLocalRollback: "マスターノードは直接ロールバックをサポートしていません。手動で「1pctl restore」コマンドを実行してロールバックしてください!"
6667

6768
# alert
6869
ErrAlertSync: "アラート情報の同期エラーです。後で再試行してください!"

0 commit comments

Comments
 (0)