From 245bbf651b5f15f31fbb69997cbe86079ec5cfba Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 11 Apr 2023 22:26:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=8B=E8=BD=BD=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#581)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/cornjob.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/backend/app/service/cornjob.go b/backend/app/service/cornjob.go index fabc07dfd..9c44b2b27 100644 --- a/backend/app/service/cornjob.go +++ b/backend/app/service/cornjob.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "os" + "path" "time" "github.com/1Panel-dev/1Panel/backend/app/dto" @@ -130,24 +131,19 @@ func (u *CronjobService) Download(down dto.CronjobDownload) (string, error) { if cronjob.ID == 0 { return "", constant.ErrRecordNotFound } - if backup.Type == "LOCAL" { + if backup.Type == "LOCAL" || record.FromLocal { if _, err := os.Stat(record.File); err != nil && os.IsNotExist(err) { return "", constant.ErrRecordNotFound } return record.File, nil } - if record.FromLocal { - local, _ := loadLocalDir() - if _, err := os.Stat(local + "/" + record.File); err == nil { - return local + "/" + record.File, nil - } - } client, err := NewIBackupService().NewClient(&backup) if err != nil { return "", err } tempPath := fmt.Sprintf("%s/download/%s", constant.DataDir, record.File) - isOK, _ := client.Download(record.File, tempPath) + _ = os.MkdirAll(path.Dir(tempPath), os.ModePerm) + isOK, err := client.Download(record.File, tempPath) if !isOK || err != nil { return "", constant.ErrRecordNotFound }