mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:40:59 +08:00
feat: 备份优化
This commit is contained in:
@@ -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 列表
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 面板每日任务
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user