diff --git a/models/task.go b/models/task.go index a96b17e..81ed9e2 100644 --- a/models/task.go +++ b/models/task.go @@ -88,22 +88,22 @@ func runTask(task *Task, msgs ...interface{}) string { io.Copy(f, r.Body) f.Close() } else { - // if path != task.Path && task.Name != task.Path { - // f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777) - // if err != nil { - // logs.Warn("打开%s失败,", path, err) - // return "" - // } - // f2, err := os.Open(task.Path) - // if err != nil { - // f.Close() - // logs.Warn("打开%s失败,", path, err) - // return "" - // } - // io.Copy(f, f2) - // f2.Close() - // f.Close() - // } + if path != task.Path && task.Name != task.Path { + f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777) + if err != nil { + logs.Warn("打开%s失败,", path, err) + return "" + } + f2, err := os.Open(task.Path) + if err != nil { + f.Close() + logs.Warn("打开%s失败,", path, err) + return "" + } + io.Copy(f, f2) + f2.Close() + f.Close() + } } lan := Config.Node if strings.Contains(task.Name, ".py") {