From faefd8cfca09790191704e1de0cdf12381c2a1a7 Mon Sep 17 00:00:00 2001 From: mountain Date: Tue, 13 Jun 2023 11:18:22 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8F=B4=EB=8D=94=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/http_api.go | 8 -------- server/http_handler.go | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/http_api.go b/server/http_api.go index 9a3c68a..8b29c90 100644 --- a/server/http_api.go +++ b/server/http_api.go @@ -2,9 +2,7 @@ package server import ( "encoding/json" - "errors" "io" - "io/fs" "net/http" "os" "path" @@ -27,12 +25,6 @@ func (h *houstonHandler) GetAgents(w http.ResponseWriter, r *http.Request) { func (h *houstonHandler) GetDeploySources(w http.ResponseWriter, r *http.Request) { files, err := os.ReadDir(h.deployPath) - if err != nil { - if errors.Is(err, fs.ErrNotExist) { - err = os.MkdirAll("deploys", 0775) - } - } - if err != nil { logger.Error(err) w.WriteHeader(http.StatusInternalServerError) diff --git a/server/http_handler.go b/server/http_handler.go index ffba150..4707165 100644 --- a/server/http_handler.go +++ b/server/http_handler.go @@ -49,6 +49,14 @@ func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string h.deployPath = path.Join(storagePath, "deploys") h.downloadPath = path.Join(storagePath, "downloads") + if err := os.MkdirAll(h.deployPath, 0775); err != nil { + return err + } + + if err := os.MkdirAll(h.downloadPath, 0775); err != nil { + return err + } + logger.Printf("houstonHandler registed. deployPath : %s, downloadPath : %s", h.deployPath, h.downloadPath) if len(prefix) > 0 {