From 8e3751d0b7ef5f97025ec57d383557e5df6443fc Mon Sep 17 00:00:00 2001 From: cong meng Date: Tue, 22 Jun 2021 12:58:54 +1200 Subject: [PATCH] fix(stack) Unable to update and redeploy a stack created from a git repository if it has failed once EE-1012 (#5212) testing passed --- api/http/handler/stacks/stack_update_git.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/api/http/handler/stacks/stack_update_git.go b/api/http/handler/stacks/stack_update_git.go index 1daefec19..dd38365b9 100644 --- a/api/http/handler/stacks/stack_update_git.go +++ b/api/http/handler/stacks/stack_update_git.go @@ -116,6 +116,13 @@ func (handler *Handler) stackUpdateGit(w http.ResponseWriter, r *http.Request) * return &httperror.HandlerError{http.StatusInternalServerError, "Unable to clone git repository", err} } + defer func() { + err = handler.FileService.RemoveDirectory(backupProjectPath) + if err != nil { + log.Printf("[WARN] [http,stacks,git] [error: %s] [message: unable to remove git repository directory]", err) + } + }() + httpErr := handler.deployStack(r, stack, endpoint) if httpErr != nil { return httpErr @@ -126,11 +133,6 @@ func (handler *Handler) stackUpdateGit(w http.ResponseWriter, r *http.Request) * return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist the stack changes inside the database", err} } - err = handler.FileService.RemoveDirectory(backupProjectPath) - if err != nil { - return &httperror.HandlerError{http.StatusInternalServerError, "Unable to remove git repository directory", err} - } - return response.JSON(w, stack) }