mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-09-15 19:15:31 +08:00
fix: 解决本地备份文件被删除导致的备份列表读取错误 (#3384)
This commit is contained in:
parent
6b491710c9
commit
10bd640a9b
5 changed files with 10 additions and 7 deletions
|
@ -91,8 +91,10 @@ func (u *BackupService) SearchRecordsWithPage(search dto.RecordSearch) (int64, [
|
||||||
}
|
}
|
||||||
itemPath := path.Join(records[i].FileDir, records[i].FileName)
|
itemPath := path.Join(records[i].FileDir, records[i].FileName)
|
||||||
if records[i].Source == "LOCAL" {
|
if records[i].Source == "LOCAL" {
|
||||||
fileInfo, _ := os.Stat(itemPath)
|
fileInfo, err := os.Stat(itemPath)
|
||||||
|
if err == nil {
|
||||||
item.Size = fileInfo.Size()
|
item.Size = fileInfo.Size()
|
||||||
|
}
|
||||||
datas = append(datas, item)
|
datas = append(datas, item)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
@ -70,7 +71,7 @@ func (u *BackupService) AppRecover(req dto.CommonRecover) error {
|
||||||
|
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
if !fileOp.Stat(req.File) {
|
if !fileOp.Stat(req.File) {
|
||||||
return errors.New(fmt.Sprintf("%s file is not exist", req.File))
|
return buserr.WithName("ErrFileNotFound", req.File)
|
||||||
}
|
}
|
||||||
if _, err := compose.Down(install.GetComposePath()); err != nil {
|
if _, err := compose.Down(install.GetComposePath()); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -2,6 +2,7 @@ package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -13,7 +14,6 @@ import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/mysql/client"
|
"github.com/1Panel-dev/1Panel/backend/utils/mysql/client"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (u *BackupService) MysqlBackup(req dto.CommonBackup) error {
|
func (u *BackupService) MysqlBackup(req dto.CommonBackup) error {
|
||||||
|
@ -125,7 +125,7 @@ func handleMysqlRecover(req dto.CommonRecover, isRollback bool) error {
|
||||||
isOk := false
|
isOk := false
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
if !fileOp.Stat(req.File) {
|
if !fileOp.Stat(req.File) {
|
||||||
return errors.New(fmt.Sprintf("%s file is not exist", req.File))
|
return buserr.WithName("ErrFileNotFound", req.File)
|
||||||
}
|
}
|
||||||
dbInfo, err := mysqlRepo.Get(commonRepo.WithByName(req.DetailName), mysqlRepo.WithByMysqlName(req.Name))
|
dbInfo, err := mysqlRepo.Get(commonRepo.WithByName(req.DetailName), mysqlRepo.WithByMysqlName(req.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -111,7 +111,7 @@ func handleRedisBackup(redisInfo *repo.RootInfo, backupDir, fileName string) err
|
||||||
func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback bool) error {
|
func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback bool) error {
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
if !fileOp.Stat(recoverFile) {
|
if !fileOp.Stat(recoverFile) {
|
||||||
return fmt.Errorf("%s file is not exist", recoverFile)
|
return buserr.WithName("ErrFileNotFound", recoverFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
appendonly, err := configGetStr(redisInfo.ContainerName, redisInfo.Password, "appendonly")
|
appendonly, err := configGetStr(redisInfo.ContainerName, redisInfo.Password, "appendonly")
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (u *BackupService) WebsiteBackup(req dto.CommonBackup) error {
|
||||||
func (u *BackupService) WebsiteRecover(req dto.CommonRecover) error {
|
func (u *BackupService) WebsiteRecover(req dto.CommonRecover) error {
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
if !fileOp.Stat(req.File) {
|
if !fileOp.Stat(req.File) {
|
||||||
return errors.New(fmt.Sprintf("%s file is not exist", req.File))
|
return buserr.WithName("ErrFileNotFound", req.File)
|
||||||
}
|
}
|
||||||
website, err := websiteRepo.GetFirst(websiteRepo.WithAlias(req.DetailName))
|
website, err := websiteRepo.GetFirst(websiteRepo.WithAlias(req.DetailName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue