From 384fc840390e01eb2096fede4bb9ecb771a1f7d9 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Sun, 13 Aug 2023 06:48:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=A4=87=E4=BB=BD?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98=20(#1938?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/cronjob_helper.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/app/service/cronjob_helper.go b/backend/app/service/cronjob_helper.go index 4627ff191..dea52f6e7 100644 --- a/backend/app/service/cronjob_helper.go +++ b/backend/app/service/cronjob_helper.go @@ -221,12 +221,14 @@ func handleTar(sourceDir, targetDir, name, exclusionRules string) error { path = sourceDir } - commands := fmt.Sprintf("tar --warning=no-file-changed zcvf %s %s %s", targetDir+"/"+name, excludeRules, path) + commands := fmt.Sprintf("tar --warning=no-file-changed -zcf %s %s %s", targetDir+"/"+name, excludeRules, path) global.LOG.Debug(commands) stdout, err := cmd.ExecWithTimeOut(commands, 24*time.Hour) if err != nil { - global.LOG.Errorf("do handle tar failed, stdout: %s, err: %v", stdout, err) - return errors.New(stdout) + if len(stdout) != 0 { + global.LOG.Errorf("do handle tar failed, stdout: %s, err: %v", stdout, err) + return fmt.Errorf("do handle tar failed, stdout: %s, err: %v", stdout, err) + } } return nil }