mirror of
https://github.com/tnb-labs/panel.git
synced 2026-08-30 17:05:19 +08:00
fix: 获取备份路径时自动创建目录
修复上传 MySQL 等备份文件时,因备份目录(如 /backup/mysql/)不存在导致 报错"文件不存在"的问题。将创建目录逻辑收敛到 GetDefaultPath,所有调用方均受益。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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 切割日志
|
||||
|
||||
Reference in New Issue
Block a user