mirror of https://github.com/1Panel-dev/1Panel
feat: SFTP Client 增加可连接性校验 (#3834)
parent
140cd564da
commit
9e980e8e0c
|
@ -314,9 +314,9 @@ var UpdateCronjobSpec = &gormigrate.Migration{
|
|||
}
|
||||
|
||||
var records []model.JobRecords
|
||||
_ = tx.Where("cronjob_id = ? AND status = ?", job.ID, constant.StatusSuccess).Find(&records).Error
|
||||
_ = tx.Where("cronjob_id = ?", job.ID).Find(&records).Error
|
||||
for _, record := range records {
|
||||
if job.Type == "snapshot" {
|
||||
if job.Type == "snapshot" && job.Status == constant.StatusSuccess {
|
||||
var snaps []model.Snapshot
|
||||
_ = tx.Where("name like ?", "snapshot_"+"%").Find(&snaps).Error
|
||||
for _, snap := range snaps {
|
||||
|
@ -337,7 +337,7 @@ var UpdateCronjobSpec = &gormigrate.Migration{
|
|||
}
|
||||
continue
|
||||
}
|
||||
if job.Type == "log" {
|
||||
if job.Type == "log" && job.Status == constant.StatusSuccess {
|
||||
item := model.BackupRecord{
|
||||
From: "cronjob",
|
||||
CronjobID: job.ID,
|
||||
|
@ -354,7 +354,7 @@ var UpdateCronjobSpec = &gormigrate.Migration{
|
|||
_ = tx.Create(&item).Error
|
||||
continue
|
||||
}
|
||||
if job.Type == "directory" {
|
||||
if job.Type == "directory" && job.Status == constant.StatusSuccess {
|
||||
item := model.BackupRecord{
|
||||
From: "cronjob",
|
||||
CronjobID: job.ID,
|
||||
|
|
|
@ -34,6 +34,9 @@ func NewSftpClient(vars map[string]interface{}) (*sftpClient, error) {
|
|||
return nil
|
||||
},
|
||||
}
|
||||
if _, err := ssh.Dial("tcp", fmt.Sprintf("%s:%s", address, port), clientConfig); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &sftpClient{bucket: bucket, connInfo: fmt.Sprintf("%s:%s", address, port), config: clientConfig}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue