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)
|
http.Error(w, "error", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(dir)
|
defer rmIfNot(dir, h.config.doNotDeleteTmp)
|
||||||
|
|
||||||
cache := path.Join("cache/", hook.Repository.FullName)
|
cache := path.Join("cache/", hook.Repository.FullName)
|
||||||
if err = os.MkdirAll(cache, 0700); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func rmIfNot(dir string, doNotDelete bool) {
|
||||||
|
if !doNotDelete {
|
||||||
|
os.RemoveAll(dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type recWebhook struct {
|
type recWebhook struct {
|
||||||
Repository recRepository `json:"repository"`
|
Repository recRepository `json:"repository"`
|
||||||
AfterCommit string `json:"after"`
|
AfterCommit string `json:"after"`
|
||||||
|
|
Loading…
Reference in a new issue