From 5814e98f4dfeeb8c5563340350fd04205b0c4da2 Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Tue, 17 Aug 2021 17:53:42 +0800 Subject: [PATCH] x --- models/task.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) 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") {