mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 16:29:17 +08:00
fix: 解决计划任务下载失败的问题 (#581)
This commit is contained in:
parent
a8b83cf4ed
commit
245bbf651b
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"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 {
|
if cronjob.ID == 0 {
|
||||||
return "", constant.ErrRecordNotFound
|
return "", constant.ErrRecordNotFound
|
||||||
}
|
}
|
||||||
if backup.Type == "LOCAL" {
|
if backup.Type == "LOCAL" || record.FromLocal {
|
||||||
if _, err := os.Stat(record.File); err != nil && os.IsNotExist(err) {
|
if _, err := os.Stat(record.File); err != nil && os.IsNotExist(err) {
|
||||||
return "", constant.ErrRecordNotFound
|
return "", constant.ErrRecordNotFound
|
||||||
}
|
}
|
||||||
return record.File, nil
|
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)
|
client, err := NewIBackupService().NewClient(&backup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
tempPath := fmt.Sprintf("%s/download/%s", constant.DataDir, record.File)
|
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 {
|
if !isOK || err != nil {
|
||||||
return "", constant.ErrRecordNotFound
|
return "", constant.ErrRecordNotFound
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user