From 9e5381710f46c5aae29c0c6aeeb9328e6949f4fd Mon Sep 17 00:00:00 2001 From: LinkLeong Date: Tue, 12 Sep 2023 09:16:18 +0100 Subject: [PATCH] update file task --- service/file.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/service/file.go b/service/file.go index 049994a..2eab5f0 100644 --- a/service/file.go +++ b/service/file.go @@ -102,16 +102,20 @@ func FileOperate(k string) { os.RemoveAll(temp.To + "/" + lastPath) } } - err := os.Rename(v.From, temp.To+"/"+lastPath) - if err != nil { - logger.Error("file move error", zap.Any("err", err)) - err = file.MoveFile(v.From, temp.To+"/"+lastPath) + err := file.CopyDir(v.From, temp.To, temp.Style) + if err == nil { + err = os.RemoveAll(v.From) if err != nil { - logger.Error("MoveFile error", zap.Any("err", err)) - continue - } + logger.Error("file move error", zap.Any("err", err)) + err = file.MoveFile(v.From, temp.To+"/"+lastPath) + if err != nil { + logger.Error("MoveFile error", zap.Any("err", err)) + continue + } + } } + } else if temp.Type == "copy" { err := file.CopyDir(v.From, temp.To, temp.Style) if err != nil {