mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-23 15:41:39 +00:00
Gitea keeps completed Actions runs forever. Artifacts and logs expire on their own schedule, but the run rows never go away, so `action_run` and its child tables grow without bound. Adds `RUN_RETENTION_DAYS` to delete completed runs along with their jobs, tasks and anything the earlier expiries left behind. It defaults to 400 days, matching how long GitHub keeps run history browsable. A dedicated `cleanup_action_runs` cron task performs the cleanup, so admins can schedule it separately from the nightly artifact and log sweep. `0` now means "keep forever" for all three retention settings, where `LOG_RETENTION_DAYS` and `ARTIFACT_RETENTION_DAYS` previously took it literally and deleted everything at the next sweep. Docs: https://gitea.com/gitea/docs/pulls/502 ---- ## ⚠️ BREAKING ⚠️ `RUN_RETENTION_DAYS` defaults to 400, so completed runs older than that are deleted when the cron task next runs at midnight. Set `RUN_RETENTION_DAYS = 0` before upgrading to keep all runs. --------- Co-authored-by: bircni <bircni@icloud.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
89 lines
2.4 KiB
Go
89 lines
2.4 KiB
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package context
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
"gitea.dev/modules/base"
|
|
"gitea.dev/modules/optional"
|
|
"gitea.dev/modules/util"
|
|
)
|
|
|
|
// FormString returns the first value matching the provided key in the form as a string
|
|
// It works the same as http.Request.FormValue:
|
|
// try urlencoded request body first, then query string, then multipart form body
|
|
func (b *Base) FormString(key string, def ...string) string {
|
|
s := b.Req.FormValue(key)
|
|
if s == "" {
|
|
s = util.OptionalArg(def)
|
|
}
|
|
return s
|
|
}
|
|
|
|
// FormStrings returns a values for the key in the form (including query parameters), similar to FormString
|
|
func (b *Base) FormStrings(key string) []string {
|
|
if b.Req.Form == nil {
|
|
if err := b.Req.ParseMultipartForm(32 << 20); err != nil {
|
|
return nil
|
|
}
|
|
}
|
|
if v, ok := b.Req.Form[key]; ok {
|
|
return v
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (b *Base) FormStringInt64s(key string) []int64 {
|
|
vals, _ := base.StringsToInt64s(strings.Split(b.FormString(key), ","))
|
|
return vals
|
|
}
|
|
|
|
// FormTrim returns the first value for the provided key in the form as a space trimmed string
|
|
func (b *Base) FormTrim(key string) string {
|
|
return strings.TrimSpace(b.Req.FormValue(key))
|
|
}
|
|
|
|
// FormInt returns the first value for the provided key in the form as an int
|
|
func (b *Base) FormInt(key string) int {
|
|
v, _ := strconv.Atoi(b.Req.FormValue(key))
|
|
return v
|
|
}
|
|
|
|
// FormInt64 returns the first value for the provided key in the form as an int64
|
|
func (b *Base) FormInt64(key string) int64 {
|
|
v, _ := strconv.ParseInt(b.Req.FormValue(key), 10, 64)
|
|
return v
|
|
}
|
|
|
|
// FormBool returns true if the value for the provided key in the form is "1", "true" or "on"
|
|
func (b *Base) FormBool(key string) bool {
|
|
s := b.Req.FormValue(key)
|
|
v, _ := strconv.ParseBool(s)
|
|
v = v || strings.EqualFold(s, "on")
|
|
return v
|
|
}
|
|
|
|
// FormOptionalBool returns an optional.Some(true) or optional.Some(false) if the value
|
|
// for the provided key exists in the form else it returns optional.None[bool]()
|
|
func (b *Base) FormOptionalBool(key string) optional.Option[bool] {
|
|
s := b.Req.FormValue(key)
|
|
if s == "" {
|
|
return optional.None[bool]()
|
|
}
|
|
v, _ := strconv.ParseBool(s)
|
|
v = v || strings.EqualFold(s, "on")
|
|
return optional.Some(v)
|
|
}
|
|
|
|
func (b *Base) FormOptionalInt64(key string) optional.Option[int64] {
|
|
s := b.Req.FormValue(key)
|
|
v, err := strconv.ParseInt(s, 10, 64)
|
|
if s == "" || err != nil {
|
|
return optional.None[int64]()
|
|
}
|
|
return optional.Some(v)
|
|
}
|