mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-11 16:06:02 +08:00
fix: Fix import issues of shell cronjob (#9726)
This commit is contained in:
parent
bc376ec495
commit
ed3e738fff
1 changed files with 5 additions and 4 deletions
|
@ -276,15 +276,16 @@ func (u *CronjobService) Import(req []dto.CronjobTrans) error {
|
|||
cronjob.DBName = strings.Join(dbIDs, ",")
|
||||
case "shell":
|
||||
if len(item.ContainerName) != 0 {
|
||||
cronjob.Script = item.Script
|
||||
client, err := docker.NewDockerClient()
|
||||
if err != nil {
|
||||
hasNotFound = true
|
||||
continue
|
||||
break
|
||||
}
|
||||
defer client.Close()
|
||||
if _, err := client.ContainerStats(context.Background(), item.ContainerName, false); err != nil {
|
||||
hasNotFound = true
|
||||
continue
|
||||
break
|
||||
}
|
||||
}
|
||||
switch item.ScriptMode {
|
||||
|
@ -292,13 +293,13 @@ func (u *CronjobService) Import(req []dto.CronjobTrans) error {
|
|||
library, _ := scriptRepo.Get(repo.WithByName(item.ScriptName))
|
||||
if library.ID == 0 {
|
||||
hasNotFound = true
|
||||
continue
|
||||
break
|
||||
}
|
||||
cronjob.ScriptID = library.ID
|
||||
case "select":
|
||||
if _, err := os.Stat(item.Script); err != nil {
|
||||
hasNotFound = true
|
||||
continue
|
||||
break
|
||||
}
|
||||
cronjob.Script = item.Script
|
||||
case "input":
|
||||
|
|
Loading…
Add table
Reference in a new issue