gitea-ci: no borrar tmp si la config lo pide
This commit is contained in:
parent
85f1a81ecc
commit
938308dc7d
1 changed files with 7 additions and 1 deletions
|
@ -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"`
|
||||
|
|
Loading…
Reference in a new issue