From d8ccbf209c7e5a8bfcceccf0bdebb26de16afdbc Mon Sep 17 00:00:00 2001 From: mklee Date: Tue, 13 May 2025 17:37:24 +0900 Subject: [PATCH] =?UTF-8?q?[1.2]=20=EB=A6=AC=ED=94=8C=EB=A0=88=EC=9D=B4=20?= =?UTF-8?q?-=20=EB=A6=AC=ED=94=8C=EB=A0=88=EC=9D=B4=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EC=9C=A0=EC=A7=80=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client.go | 24 ++++++++++++++---------- client/houston_pipe_req.go | 3 ++- client/operation.go | 9 +++++---- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/client/client.go b/client/client.go index 736e196..1498a93 100644 --- a/client/client.go +++ b/client/client.go @@ -34,9 +34,9 @@ import ( ) type runcommand struct { - Exec string `json:"exec"` - Args []string `json:"args"` - Version string `json:"version"` + Exec string `json:"exec"` + Args []string `json:"args"` + Version string `json:"version"` } type clientConfig struct { @@ -98,9 +98,10 @@ func (pm *procmeta) setState(s protos.ProcessState) { } type uploadRequest struct { - filePath string - name string - version string + filePath string + name string + version string + uploadedFileName string } type houstonClient struct { @@ -503,7 +504,7 @@ func NewClient(standalone bool) (HoustonClient, error) { return hc, nil } -func uploadSafe(url, filePath, name, version string) error { +func uploadSafe(url, filePath, name, version, uploadedFileName string) error { defer func() { r := recover() if r != nil { @@ -537,7 +538,10 @@ func uploadSafe(url, filePath, name, version string) error { // createTime := file. httpreq.Header.Set("Houston-Service-Name", name) httpreq.Header.Set("Houston-Service-Version", version) - httpreq.Header.Set("Houston-Service-Filename", t.BirthTime().UTC().Format(time.DateOnly)+"."+hn+path.Ext(filePath)) + if len(uploadedFileName) == 0 { + uploadedFileName = t.BirthTime().UTC().Format(time.DateOnly) + "." + hn + path.Ext(filePath) + } + httpreq.Header.Set("Houston-Service-Filename", uploadedFileName) httpreq.Header.Set("Content-Type", "application/zip") resp, err := http.DefaultClient.Do(httpreq) if err != nil { @@ -581,7 +585,7 @@ func (hc *houstonClient) Start() { url := hc.config.HttpAddress + "/upload" for req := range hc.uploadChan { logger.Println("uploadSafe :", req) - err := uploadSafe(url, req.filePath, req.name, req.version) + err := uploadSafe(url, req.filePath, req.name, req.version, req.uploadedFileName) if err != nil { logger.Println("uploadSafe return err :", err) } @@ -630,8 +634,8 @@ func (hc *houstonClient) Start() { logger.Println("autorun success :", sr) } } - } } + } for { select { diff --git a/client/houston_pipe_req.go b/client/houston_pipe_req.go index f07a1bc..df220f4 100644 --- a/client/houston_pipe_req.go +++ b/client/houston_pipe_req.go @@ -8,6 +8,7 @@ import ( "encoding/hex" "errors" "os" + "path/filepath" "strings" ) @@ -129,7 +130,7 @@ func handleStdOutUploadRequest(hc *houstonClient, meta *procmeta, param string) if _, err := os.Stat(uploadFullPath); err != nil { return err } else { - hc.uploadToAppendFile(uploadFullPath, meta.name, meta.version) + hc.uploadToAppendFile(uploadFullPath, meta.name, meta.version, filepath.Base(uploadFullPath)) } return nil } diff --git a/client/operation.go b/client/operation.go index d5d256c..db01c10 100644 --- a/client/operation.go +++ b/client/operation.go @@ -44,11 +44,12 @@ func lastExecutionArgs(verpath string) []string { return out } -func (hc *houstonClient) uploadToAppendFile(filePath string, name string, version string) { +func (hc *houstonClient) uploadToAppendFile(filePath string, name string, version string, uploadedFileName string) { hc.uploadChan <- uploadRequest{ - filePath: filePath, - name: name, - version: version, + filePath: filePath, + name: name, + version: version, + uploadedFileName: uploadedFileName, } }