feat: Optimize snapshot backup items (#11385)

This commit is contained in:
ssongliu
2025-12-18 07:43:13 +00:00
committed by GitHub
parent 70e64e648f
commit 825acd5b46
4 changed files with 49 additions and 13 deletions
+11 -3
View File
@@ -263,7 +263,15 @@ func stopBeforeUpdateRepo() error {
if err := validateDockerConfig(); err != nil {
return err
}
if err := controller.HandleRestart("docker"); err != nil {
dockerService, _ := controller.LoadServiceName("docker")
if len(dockerService) == 0 {
return errors.New("docker service not found")
}
client, err := controller.New()
if err != nil {
return err
}
if err := client.Operate("restart", dockerService); err != nil {
return fmt.Errorf("failed to restart Docker: %v", err)
}
ticker := time.NewTicker(3 * time.Second)
@@ -276,8 +284,8 @@ func stopBeforeUpdateRepo() error {
cancel()
return errors.New("the docker service cannot be restarted")
default:
active, err := controller.CheckActive("docker")
if active && err != nil {
active, _ := client.IsActive(dockerService)
if active {
global.LOG.Info("docker restart with new conf successful!")
return nil
}
+17 -2
View File
@@ -336,11 +336,26 @@ func loadPanelFile(fileOp fileUtils.FileOp) ([]dto.DataTree, error) {
Path: path.Join(global.Dir.DataDir, fileItem.Name()),
}
switch itemData.Label {
case "agent", "runtime", "docker", "task", "geo", "secret", "uploads":
case "runtime", "docker", "task", "geo", "secret", "uploads":
itemData.IsDisable = true
case "clamav", "download":
panelPath := path.Join(global.Dir.DataDir, itemData.Label)
itemData.Children, _ = loadFile(panelPath, 3, fileOp)
case "agent":
panelPath := path.Join(global.Dir.DataDir, itemData.Label)
itemData.Children, _ = loadFile(panelPath, 3, fileOp)
itemData.IsCheck = false
for i := 0; i < len(itemData.Children); i++ {
if itemData.Children[i].Label != "package" {
itemData.Children[i].IsDisable = true
} else {
itemData.Size = -itemData.Children[i].Size
itemData.Children[i].IsCheck = false
for j := 0; j < len(itemData.Children[i].Children); j++ {
itemData.Children[i].Children[j].IsCheck = false
}
}
}
case "apps", "backup", "log", "db", "tmp":
continue
}
@@ -349,7 +364,7 @@ func loadPanelFile(fileOp fileUtils.FileOp) ([]dto.DataTree, error) {
if err != nil {
continue
}
itemData.Size = uint64(sizeItem)
itemData.Size = uint64(int64(sizeItem) + int64(itemData.Size))
} else {
fileInfo, err := fileItem.Info()
if err != nil {
+3 -3
View File
@@ -478,7 +478,7 @@ func (f FileOp) CopyDir(src, dst string) error {
if err = f.Fs.MkdirAll(dstDir, srcInfo.Mode()); err != nil {
return err
}
return cmd.RunDefaultBashCf(`cp -rf '%s' '%s'`, src, dst+"/")
return cmd.NewCommandMgr(cmd.WithIgnoreExist1()).RunBashCf(`cp -rf '%s' '%s'`, src, dst+"/")
}
func (f FileOp) CopyDirWithExclude(src, dst string, excludeNames []string) error {
@@ -491,7 +491,7 @@ func (f FileOp) CopyDirWithExclude(src, dst string, excludeNames []string) error
return err
}
if len(excludeNames) == 0 {
return cmd.RunDefaultBashCf(`cp -rf '%s' '%s'`, src, dst+"/")
return cmd.NewCommandMgr(cmd.WithIgnoreExist1()).RunBashCf(`cp -rf '%s' '%s'`, src, dst+"/")
}
tmpFiles, err := os.ReadDir(src)
if err != nil {
@@ -524,7 +524,7 @@ func (f FileOp) CopyDirWithExclude(src, dst string, excludeNames []string) error
func (f FileOp) CopyFile(src, dst string) error {
dst = filepath.Clean(dst) + string(filepath.Separator)
return cmd.RunDefaultBashCf(`cp -f '%s' '%s'`, src, dst+"/")
return cmd.NewCommandMgr(cmd.WithIgnoreExist1()).RunBashCf(`cp -f '%s' '%s'`, src, dst+"/")
}
func (f FileOp) GetDirSize(path string) (int64, error) {
+18 -5
View File
@@ -105,7 +105,7 @@
</LayoutContent>
<OperateDialog @search="loadConnShow" ref="dialogRef" />
<OpDialog ref="opRef" @search="search" @cancel="loadConnShow">
<OpDialog ref="opRef" @search="search" @cancel="loadConnShow" @submit="submitChangeShow">
<template #content>
<el-form class="mt-4 mb-1" ref="deleteForm" v-if="!form.showDefaultConn" label-position="left">
<el-form-item>
@@ -200,12 +200,25 @@ const changeShow = async () => {
title: i18n.global.t('terminal.defaultConn'),
names: [],
msg: i18n.global.t('terminal.defaultConnHelper', [op]),
noMsg: false,
successMsg: i18n.global.t('commons.msg.operationSuccess'),
api: updateLocalConn,
params: { withReset: resetConn.value, defaultConn: form.showDefaultConn ? 'Enable' : 'Disable' },
api: null,
params: {},
});
};
const submitChangeShow = async () => {
loading.value = true;
await updateLocalConn({
withReset: resetConn.value,
defaultConn: form.showDefaultConn ? 'Enable' : 'Disable',
})
.then(() => {
loading.value = false;
loadConnShow();
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
})
.finally(() => {
loading.value = false;
});
};
const iniTerm = () => {
term.value = new Terminal({