gitea-ci: no borrar tmp si la config lo pide

This commit is contained in:
Cat /dev/Nulo 2023-01-26 16:36:39 -03:00
parent 85f1a81ecc
commit 938308dc7d

View file

@ -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"`