Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Jun 8, 2024
1 parent 8ad42f8 commit 688801e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
11 changes: 9 additions & 2 deletions app/console/commands/panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,25 @@ func (receiver *Panel) Handle(ctx console.Context) error {

case "update":
var task models.Task
err := facades.Orm().Query().Where("status", models.TaskStatusRunning).OrWhere("status", models.TaskStatusWaiting).FirstOrFail(&task)
if err == nil {
if err := facades.Orm().Query().Where("status", models.TaskStatusRunning).OrWhere("status", models.TaskStatusWaiting).FirstOrFail(&task); err == nil {
color.Red().Printfln(translate.Get("commands.panel.update.taskCheck"))
return nil
}
if _, err := facades.Orm().Query().Exec("PRAGMA wal_checkpoint(TRUNCATE)"); err != nil {
types.Status = types.StatusFailed
color.Red().Printfln(translate.Get("commands.panel.update.dbFail"))
return nil
}

panel, err := tools.GetLatestPanelVersion()
if err != nil {
color.Red().Printfln(translate.Get("commands.panel.update.versionFail"))
return err
}

// 停止面板服务,因为在shell中运行的和systemd的不同
_ = tools.ServiceStop("panel")

types.Status = types.StatusUpgrade
if err = tools.UpdatePanel(panel); err != nil {
types.Status = types.StatusFailed
Expand Down
7 changes: 5 additions & 2 deletions app/http/controllers/info_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,13 @@ func (r *InfoController) UpdateInfo(ctx http.Context) http.Response {
// Update 更新面板
func (r *InfoController) Update(ctx http.Context) http.Response {
var task models.Task
err := facades.Orm().Query().Where("status", models.TaskStatusRunning).OrWhere("status", models.TaskStatusWaiting).FirstOrFail(&task)
if err == nil {
if err := facades.Orm().Query().Where("status", models.TaskStatusRunning).OrWhere("status", models.TaskStatusWaiting).FirstOrFail(&task); err == nil {
return Error(ctx, http.StatusInternalServerError, "当前有任务正在执行,禁止更新")
}
if _, err := facades.Orm().Query().Exec("PRAGMA wal_checkpoint(TRUNCATE)"); err != nil {
types.Status = types.StatusFailed
return Error(ctx, http.StatusInternalServerError, fmt.Sprintf("面板数据库异常,已终止操作:%s", err.Error()))
}

panel, err := tools.GetLatestPanelVersion()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion app/http/controllers/plugins/frp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (r *FrpController) Status(ctx http.Context) http.Response {
func (r *FrpController) IsEnabled(ctx http.Context) http.Response {
frps, err := tools.ServiceIsEnabled("frps")
if err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, "获取 frps 服务启用状态失败:"+err.Error())
return controllers.Error(ctx, http.StatusInternalServerError, "获取 frps 服务启用状态失败")
}
frpc, err := tools.ServiceIsEnabled("frpc")
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"update": {
"description": "update/fix panel to latest version",
"taskCheck": "There is currently a task being executed and updates are prohibited.",
"dbFail": "panel database exception, operation terminated",
"versionFail": "failed to get latest version",
"fail": "update failed",
"success": "update completed"
Expand Down Expand Up @@ -76,7 +77,7 @@
"databaseGetFail": "failed to get database",
"databaseNotExist": "database does not exist",
"targetPostgres": "target PostgreSQL database",
"cleanBackup" : "clean backup",
"cleanBackup": "clean backup",
"cleanupFail": "cleanup failed",
"cleanupSuccess": "cleanup successful",
"deleteFail": "failed to delete",
Expand Down
1 change: 1 addition & 0 deletions lang/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"update": {
"description": "更新 / 修复面板到最新版本",
"taskCheck": "当前有任务正在执行,禁止更新",
"dbFail": "面板数据库异常,已终止操作",
"versionFail": "获取最新版本失败",
"fail": "更新失败",
"success": "更新成功"
Expand Down

0 comments on commit 688801e

Please sign in to comment.