From dfcb78b70c223f6fdeb574b0e4f9391e9429ffc0 Mon Sep 17 00:00:00 2001 From: mountain Date: Wed, 5 Jun 2024 17:26:17 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=ED=8C=8C=EC=9D=BC=EC=97=90?= =?UTF-8?q?=20=ED=98=B8=EC=8A=A4=ED=8A=B8=EC=9D=B4=EB=A6=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/operation.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/client/operation.go b/client/operation.go index 93839a4..6e66cd6 100644 --- a/client/operation.go +++ b/client/operation.go @@ -93,7 +93,8 @@ func zipLogFiles(storageRoot string, req *shared.UploadRequest) (string, []strin } root = path.Join(root, path.Dir(req.Filter)) - zipFileName := path.Join(os.TempDir(), path.Base(filepath.ToSlash(matches[0]))) + ".zip" + hostname, _ := os.Hostname() + zipFileName := path.Join(os.TempDir(), hostname+"_"+path.Base(filepath.ToSlash(matches[0]))) + ".zip" os.Remove(zipFileName) f, err := os.OpenFile(zipFileName, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) @@ -537,11 +538,18 @@ func (hc *houstonClient) uploadFiles(req *shared.UploadRequest) error { if err == nil && len(zipFile) > 0 && len(srcFiles) > 0 { if err = hc.uploadZipLogFile(zipFile, child.name, child.version); err == nil { // 마지막거 빼고 삭제 - sort.StringSlice(srcFiles).Sort() - for i := 0; i < len(srcFiles)-1; i++ { - if len(srcFiles[i]) > 0 { + if req.DeleteAfterUploaded == "true" { + for i := 0; i < len(srcFiles)-1; i++ { os.Remove(srcFiles[i]) } + } else { + sort.StringSlice(srcFiles).Sort() + + for i := 0; i < len(srcFiles)-1; i++ { + if len(srcFiles[i]) > 0 { + os.Remove(srcFiles[i]) + } + } } } else { logger.Println("uploadZipLogFile failed :", err)