From cbabd963dfd5d2aa3ee39558a3e29ed2b18cb1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Thu, 4 Jun 2026 04:05:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=8E=B7=E5=8F=96=E5=A4=87=E4=BB=BD?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E6=97=B6=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复上传 MySQL 等备份文件时,因备份目录(如 /backup/mysql/)不存在导致 报错"文件不存在"的问题。将创建目录逻辑收敛到 GetDefaultPath,所有调用方均受益。 Co-Authored-By: Claude Opus 4.8 (1M context) --- internal/data/backup.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/data/backup.go b/internal/data/backup.go index d97463d9..942f0cc1 100644 --- a/internal/data/backup.go +++ b/internal/data/backup.go @@ -260,9 +260,11 @@ func (r *backupRepo) Restore(ctx context.Context, typ biz.BackupType, backup, ta func (r *backupRepo) GetDefaultPath(typ biz.BackupType) string { backupPath, err := r.setting.Get(biz.SettingKeyBackupPath) if err != nil { - return filepath.Join(app.Root, "backup", string(typ)) + backupPath = filepath.Join(app.Root, "backup") } - return filepath.Join(backupPath, string(typ)) + path := filepath.Join(backupPath, string(typ)) + _ = os.MkdirAll(path, 0755) + return path } // CutoffLog 切割日志