diff --git a/internal/apps/nginx/stream.go b/internal/apps/nginx/stream.go index 7cf9d5d7..50a52f73 100644 --- a/internal/apps/nginx/stream.go +++ b/internal/apps/nginx/stream.go @@ -9,11 +9,12 @@ import ( "strings" "time" + "github.com/go-chi/chi/v5" + "github.com/acepanel/panel/internal/app" "github.com/acepanel/panel/internal/service" "github.com/acepanel/panel/pkg/systemctl" webserverNginx "github.com/acepanel/panel/pkg/webserver/nginx" - "github.com/go-chi/chi/v5" ) // ListStreamServers 获取 Stream Server 列表 diff --git a/internal/data/backup.go b/internal/data/backup.go index c820406e..2998b896 100644 --- a/internal/data/backup.go +++ b/internal/data/backup.go @@ -11,8 +11,6 @@ import ( "strings" "time" - "github.com/acepanel/panel/pkg/storage" - "github.com/acepanel/panel/pkg/types" "github.com/leonelquinteros/gotext" "gorm.io/gorm" @@ -22,7 +20,9 @@ import ( "github.com/acepanel/panel/pkg/db" "github.com/acepanel/panel/pkg/io" "github.com/acepanel/panel/pkg/shell" + "github.com/acepanel/panel/pkg/storage" "github.com/acepanel/panel/pkg/tools" + "github.com/acepanel/panel/pkg/types" ) type backupRepo struct { diff --git a/internal/data/backup_account.go b/internal/data/backup_account.go index f7abfdb9..b754651b 100644 --- a/internal/data/backup_account.go +++ b/internal/data/backup_account.go @@ -4,12 +4,12 @@ import ( "context" "log/slog" - "github.com/acepanel/panel/pkg/types" "github.com/leonelquinteros/gotext" "gorm.io/gorm" "github.com/acepanel/panel/internal/biz" "github.com/acepanel/panel/internal/http/request" + "github.com/acepanel/panel/pkg/types" ) type backupAccountRepo struct { @@ -30,22 +30,14 @@ func NewBackupAccountRepo(t *gotext.Locale, db *gorm.DB, log *slog.Logger, setti func (r backupAccountRepo) List(page, limit uint) ([]*biz.BackupAccount, int64, error) { // 本地存储 - path, err := r.setting.Get(biz.SettingKeyBackupPath) + localStorage, err := r.Get(0) if err != nil { return nil, 0, err } - localStorage := &biz.BackupAccount{ - ID: 0, - Type: biz.BackupAccountTypeLocal, - Name: r.t.Get("Local Storage"), - Info: types.BackupAccountInfo{ - Path: path, - }, - } var dbAccounts []*biz.BackupAccount var total int64 - if err = r.db.Model(&biz.BackupAccount{}).Order("id desc").Count(&total).Offset(int((page - 1) * limit)).Limit(int(limit)).Find(&dbAccounts).Error; err != nil { + if err = r.db.Model(&biz.BackupAccount{}).Order("id asc").Count(&total).Offset(int((page - 1) * limit)).Limit(int(limit)).Find(&dbAccounts).Error; err != nil { return nil, 0, err } @@ -59,6 +51,21 @@ func (r backupAccountRepo) List(page, limit uint) ([]*biz.BackupAccount, int64, } func (r backupAccountRepo) Get(id uint) (*biz.BackupAccount, error) { + if id == 0 { + path, err := r.setting.Get(biz.SettingKeyBackupPath) + if err != nil { + return nil, err + } + return &biz.BackupAccount{ + ID: 0, + Type: biz.BackupAccountTypeLocal, + Name: r.t.Get("Local Storage"), + Info: types.BackupAccountInfo{ + Path: path, + }, + }, nil + } + account := new(biz.BackupAccount) err := r.db.Model(&biz.BackupAccount{}).Where("id = ?", id).First(account).Error return account, err diff --git a/internal/data/template.go b/internal/data/template.go index d4ce3126..798d3a97 100644 --- a/internal/data/template.go +++ b/internal/data/template.go @@ -8,12 +8,13 @@ import ( "regexp" "strings" + "github.com/leonelquinteros/gotext" + "github.com/acepanel/panel/internal/app" "github.com/acepanel/panel/internal/biz" "github.com/acepanel/panel/pkg/api" "github.com/acepanel/panel/pkg/firewall" "github.com/acepanel/panel/pkg/types" - "github.com/leonelquinteros/gotext" ) type templateRepo struct { diff --git a/internal/job/panel_task.go b/internal/job/panel_task.go index 5395cac2..702510da 100644 --- a/internal/job/panel_task.go +++ b/internal/job/panel_task.go @@ -8,7 +8,6 @@ import ( "runtime/debug" "time" - "github.com/acepanel/panel/pkg/config" "github.com/hashicorp/go-version" "github.com/libtnb/utils/collect" "gorm.io/gorm" @@ -16,6 +15,7 @@ import ( "github.com/acepanel/panel/internal/app" "github.com/acepanel/panel/internal/biz" "github.com/acepanel/panel/pkg/api" + "github.com/acepanel/panel/pkg/config" ) // PanelTask 面板每日任务 diff --git a/pkg/storage/local.go b/pkg/storage/local.go index df441ac9..2a37ff33 100644 --- a/pkg/storage/local.go +++ b/pkg/storage/local.go @@ -9,8 +9,9 @@ import ( "strings" "time" - pkgio "github.com/acepanel/panel/pkg/io" "github.com/shirou/gopsutil/v4/disk" + + pkgio "github.com/acepanel/panel/pkg/io" ) type Local struct {