From 938308dc7d9d3a346bd25485e5a18dc1b8269d9c Mon Sep 17 00:00:00 2001 From: Nulo Date: Thu, 26 Jan 2023 16:36:39 -0300 Subject: [PATCH] gitea-ci: no borrar tmp si la config lo pide --- gitea-ci/webhook.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gitea-ci/webhook.go b/gitea-ci/webhook.go index a0d1d63..d8fa8ff 100644 --- a/gitea-ci/webhook.go +++ b/gitea-ci/webhook.go @@ -162,7 +162,7 @@ func (h webhook) ServeHTTP(w http.ResponseWriter, req *http.Request) { http.Error(w, "error", http.StatusInternalServerError) return } - defer os.RemoveAll(dir) + defer rmIfNot(dir, h.config.doNotDeleteTmp) cache := path.Join("cache/", hook.Repository.FullName) if err = os.MkdirAll(cache, 0700); err != nil { @@ -268,6 +268,12 @@ func (h webhook) getConfig(hook recWebhook, w http.ResponseWriter) (c *runner.Co return } +func rmIfNot(dir string, doNotDelete bool) { + if !doNotDelete { + os.RemoveAll(dir) + } +} + type recWebhook struct { Repository recRepository `json:"repository"` AfterCommit string `json:"after"`