mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-16 14:47:48 +02:00
refactor to remove ENABLE_SIZE_LIMIT option and replace it with -1 in the config.
This commit is contained in:
parent
4ef0f996b3
commit
624fe24693
@ -1084,14 +1084,22 @@ LEVEL = Info
|
||||
;; Allow to fork repositories without maximum number limit
|
||||
;ALLOW_FORK_WITHOUT_MAXIMUM_LIMIT = true
|
||||
;
|
||||
;; Enable applying a global size limit defined by REPO_SIZE_LIMIT. Each repository can have a value that overrides the global limit
|
||||
;; "false" means no limit will be enforced, even if specified on a repository
|
||||
;ENABLE_SIZE_LIMIT = false
|
||||
;
|
||||
;; Specify a global repository size limit in bytes to apply for each repository. 0 - No limit
|
||||
;; If repository has it's own limit set in UI it will override the global setting
|
||||
;; Standard units of measurements for size can be used like B, KB, KiB, ... , EB, EiB, ...
|
||||
;REPO_SIZE_LIMIT = 0
|
||||
;; Specify a global repository size limit in bytes to apply for each repository. -1 - Disabled, 0 - Enabled with no limit
|
||||
;; If repository has it's own limit set in repositiry settings UI it will override the global setting
|
||||
;; Standard units of measurements for size can be used like B, KB, KiB, ... , EB, EiB, etc or if not provided - bytes
|
||||
;; This is experimental and subject to change
|
||||
;REPO_SIZE_LIMIT = -1
|
||||
|
||||
;; Specify a global LFS size limit in bytes to apply for each repository. -1 - Disabled, 0 - Enabled with no limit
|
||||
;; If repository has it's own limit set in repository settings UI it will override the global setting
|
||||
;; Standard units of measurements for size can be used like B, KB, KiB, ... , EB, EiB, etc or if not provided - bytes
|
||||
;; This is experimental and subject to change
|
||||
;LFS_SIZE_LIMIT = -1
|
||||
;;
|
||||
;; If true, LFS size will be included in the repository size calculation.
|
||||
;; Which means even if LFS_SIZE_LIMIT is not set (-1) pushes will be rejected if LFS size + repository size exceeds REPO_SIZE_LIMIT
|
||||
;; This is experimental and subject to change
|
||||
;LFS_SIZE_IN_REPO_SIZE = false
|
||||
|
||||
;; Allow to fork repositories into the same owner (user or organization)
|
||||
;; This feature is experimental, not fully tested, and may be changed in the future
|
||||
|
||||
@ -203,7 +203,6 @@ type Repository struct {
|
||||
TemplateID int64 `xorm:"INDEX"`
|
||||
SizeLimit int64 `xorm:"NOT NULL DEFAULT 0"`
|
||||
Size int64 `xorm:"NOT NULL DEFAULT 0"`
|
||||
EnableSizeLimit bool `xorm:"NOT NULL DEFAULT true"`
|
||||
GitSize int64 `xorm:"NOT NULL DEFAULT 0"`
|
||||
LFSSize int64 `xorm:"NOT NULL DEFAULT 0"`
|
||||
LFSSizeLimit int64 `xorm:"NOT NULL DEFAULT 0"`
|
||||
@ -645,13 +644,13 @@ func (repo *Repository) GetActualSizeLimit() int64 {
|
||||
|
||||
// RepoSizeIsOversized return true if is over size limitation
|
||||
func (repo *Repository) IsRepoSizeOversized(additionalSize int64) bool {
|
||||
return setting.EnableSizeLimit && repo.GetActualSizeLimit() > 0 && repo.GitSize+additionalSize > repo.GetActualSizeLimit()
|
||||
return repo.ShouldCheckRepoSize() && repo.GitSize+additionalSize > repo.GetActualSizeLimit()
|
||||
}
|
||||
|
||||
// ShouldCheckRepoSize returns true if size limit checking is enabled and limit is non zero for this specific repository
|
||||
// this is used to enable size checking during pre-receive hook
|
||||
func (repo *Repository) ShouldCheckRepoSize() bool {
|
||||
return setting.EnableSizeLimit && repo.GetActualSizeLimit() > 0
|
||||
return setting.RepoSizeLimit > -1 && repo.GetActualSizeLimit() > 0
|
||||
}
|
||||
|
||||
// GetActualLFSSizeLimit returns repository LFS size limit in bytes
|
||||
@ -666,7 +665,7 @@ func (repo *Repository) GetActualLFSSizeLimit() int64 {
|
||||
|
||||
// ShouldCheckLFSSize returns true if LFS size limit checking is enabled for this repository
|
||||
func (repo *Repository) ShouldCheckLFSSize() bool {
|
||||
return setting.EnableSizeLimit && repo.GetActualLFSSizeLimit() > 0
|
||||
return setting.LFSSizeLimit > -1 && repo.GetActualLFSSizeLimit() > 0
|
||||
}
|
||||
|
||||
// IsLFSSizeOversized returns true if adding additionalSize would exceed the LFS size limit
|
||||
@ -678,7 +677,7 @@ func (repo *Repository) IsLFSSizeOversized(additionalSize int64) bool {
|
||||
// IsRepoAndLFSSizeOversized checks if combined repo + LFS size exceeds repo size limit
|
||||
// This is used when LFS_SIZE_IN_REPO_SIZE is enabled
|
||||
func (repo *Repository) IsRepoAndLFSSizeOversized(additionalGitSize, additionalLFSSize int64) bool {
|
||||
if !setting.LFSSizeInRepoSize || !setting.EnableSizeLimit {
|
||||
if !setting.LFSSizeInRepoSize || setting.RepoSizeLimit == -1 {
|
||||
return false
|
||||
}
|
||||
limit := repo.GetActualSizeLimit()
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"fmt"
|
||||
"hash"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
@ -92,11 +93,18 @@ func CreateTimeLimitCode[T time.Time | string](data string, minutes int, startTi
|
||||
|
||||
// FileSize calculates the file size and generate user-friendly string.
|
||||
func FileSize(s int64) string {
|
||||
if s == -1 {
|
||||
return "-1"
|
||||
}
|
||||
return humanize.IBytes(uint64(s))
|
||||
}
|
||||
|
||||
// Get FileSize bytes value from String.
|
||||
func GetFileSize(s string) (int64, error) {
|
||||
s = strings.TrimSpace(s)
|
||||
if s == "-1" {
|
||||
return -1, nil
|
||||
}
|
||||
v, err := humanize.ParseBytes(s)
|
||||
iv := int64(v)
|
||||
return iv, err
|
||||
|
||||
@ -6,6 +6,7 @@ package setting
|
||||
import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
@ -276,32 +277,50 @@ var (
|
||||
RepoRootPath string
|
||||
ScriptType = "bash"
|
||||
|
||||
EnableSizeLimit = true
|
||||
RepoSizeLimit int64
|
||||
LFSSizeLimit int64
|
||||
// Repository size limits
|
||||
RepoSizeLimit int64 = -1
|
||||
LFSSizeLimit int64 = -1
|
||||
LFSSizeInRepoSize bool
|
||||
)
|
||||
|
||||
func SaveGlobalRepositorySetting(enableSizeLimit bool, repoSizeLimit, lfsSizeLimit int64, lfsSizeInRepoSize bool) error {
|
||||
EnableSizeLimit = enableSizeLimit
|
||||
func SaveGlobalRepositorySetting(repoSizeLimit, lfsSizeLimit int64, lfsSizeInRepoSize bool) error {
|
||||
RepoSizeLimit = repoSizeLimit
|
||||
LFSSizeLimit = lfsSizeLimit
|
||||
LFSSizeInRepoSize = lfsSizeInRepoSize
|
||||
sec := CfgProvider.Section("repository")
|
||||
if EnableSizeLimit {
|
||||
sec.Key("ENABLE_SIZE_LIMIT").SetValue("true")
|
||||
} else {
|
||||
sec.Key("ENABLE_SIZE_LIMIT").SetValue("false")
|
||||
|
||||
cfg, err := CfgProvider.PrepareSaving()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sec.Key("REPO_SIZE_LIMIT").SetValue(humanize.Bytes(uint64(RepoSizeLimit)))
|
||||
sec.Key("LFS_SIZE_LIMIT").SetValue(humanize.Bytes(uint64(LFSSizeLimit)))
|
||||
if lfsSizeInRepoSize {
|
||||
sec.Key("LFS_SIZE_IN_REPO_SIZE").SetValue("true")
|
||||
sec := cfg.Section("repository")
|
||||
if RepoSizeLimit == -1 {
|
||||
sec.Key("REPO_SIZE_LIMIT").SetValue("-1")
|
||||
} else {
|
||||
sec.Key("LFS_SIZE_IN_REPO_SIZE").SetValue("false")
|
||||
sec.Key("REPO_SIZE_LIMIT").SetValue(humanize.Bytes(uint64(RepoSizeLimit)))
|
||||
}
|
||||
return nil
|
||||
if LFSSizeLimit == -1 {
|
||||
sec.Key("LFS_SIZE_LIMIT").SetValue("-1")
|
||||
} else {
|
||||
sec.Key("LFS_SIZE_LIMIT").SetValue(humanize.Bytes(uint64(LFSSizeLimit)))
|
||||
}
|
||||
sec.Key("LFS_SIZE_IN_REPO_SIZE").SetValue(strconv.FormatBool(LFSSizeInRepoSize))
|
||||
return cfg.Save()
|
||||
}
|
||||
|
||||
func parseSize(sec ConfigSection, key string, def int64) int64 {
|
||||
v := sec.Key(key).MustString("")
|
||||
if v == "" {
|
||||
return def
|
||||
}
|
||||
if v == "-1" {
|
||||
return -1
|
||||
}
|
||||
size, err := humanize.ParseBytes(v)
|
||||
if err != nil {
|
||||
return def
|
||||
}
|
||||
return int64(size)
|
||||
}
|
||||
|
||||
func loadRepositoryFrom(rootCfg ConfigProvider) {
|
||||
@ -309,12 +328,8 @@ func loadRepositoryFrom(rootCfg ConfigProvider) {
|
||||
|
||||
// Determine and create root git repository path.
|
||||
sec := rootCfg.Section("repository")
|
||||
EnableSizeLimit = sec.Key("ENABLE_SIZE_LIMIT").MustBool(false)
|
||||
|
||||
v, _ := humanize.ParseBytes(sec.Key("REPO_SIZE_LIMIT").MustString("0"))
|
||||
RepoSizeLimit = int64(v)
|
||||
v, _ = humanize.ParseBytes(sec.Key("LFS_SIZE_LIMIT").MustString("0"))
|
||||
LFSSizeLimit = int64(v)
|
||||
RepoSizeLimit = parseSize(sec, "REPO_SIZE_LIMIT", -1)
|
||||
LFSSizeLimit = parseSize(sec, "LFS_SIZE_LIMIT", -1)
|
||||
LFSSizeInRepoSize = sec.Key("LFS_SIZE_IN_REPO_SIZE").MustBool(false)
|
||||
|
||||
Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
|
||||
|
||||
@ -1188,11 +1188,14 @@ form.reach_limit_of_creation_1 = The owner has already reached the limit of %d r
|
||||
form.reach_limit_of_creation_n = The owner has already reached the limit of %d repositories.
|
||||
form.name_reserved = The repository name "%s" is reserved.
|
||||
form.name_pattern_not_allowed = The pattern "%s" is not allowed in a repository name.
|
||||
form.repo_size_limit_negative = Repository size limitation cannot be negative.
|
||||
form.invalid_repo_size_limit = Invalid format. Use -1, 0, or size (e.g. 500MiB).
|
||||
form.invalid_repo_size_limit_repo = Invalid format. Use 0 or size (e.g. 500MiB).
|
||||
form.invalid_lfs_size_limit = Invalid format. Use -1, 0, or size (e.g. 500MiB).
|
||||
form.invalid_lfs_size_limit_repo = Invalid format. Use 0 or size (e.g. 500MiB).
|
||||
form.repo_size_limit_only_by_admins = Only administrators can change the repository size limitation.
|
||||
form.invalid_lfs_size_limit = Invalid LFS size limit format.
|
||||
form.lfs_size_limit_negative = LFS size limitation cannot be negative.
|
||||
form.lfs_size_limit_only_by_admins = Only administrators can change the LFS size limitation.
|
||||
repo_size_limit_helper = Set to 0 to use the global limit.
|
||||
lfs_size_limit_helper = Set to 0 to use the global limit.
|
||||
|
||||
need_auth = Authorization
|
||||
migrate_options = Migration Options
|
||||
@ -3465,7 +3468,8 @@ config.lfs_size_in_repo_size = Count LFS in Repository Size
|
||||
config.lfs_size_in_repo_size.desc = When enabled, LFS size is included in repository size calculations
|
||||
config.global_repo_size_limit_manage_panel = Manage Global Repository Size Limit
|
||||
config.update_settings = Update Settings
|
||||
config.invalid_repo_size = Invalid repository size %s
|
||||
config.invalid_repo_size = Invalid format: %s. Use -1, 0, or size (e.g. 500MiB).
|
||||
config.invalid_lfs_size = Invalid format: %s. Use -1, 0, or size (e.g. 500MiB).
|
||||
config.save_repo_size_setting_failed = Failed to save global repository settings %s
|
||||
config.repository_setting_success = Global repository setting has been updated
|
||||
|
||||
|
||||
@ -777,6 +777,10 @@ func HookPreReceive(ctx *gitea_context.PrivateContext) {
|
||||
if _, inOld := oldLFSPtrs[oid]; !inOld {
|
||||
addedLFSSize += sz
|
||||
if _, inOther := otherLFSPtrs[oid]; !inOther {
|
||||
// Check if the object is already in the database for this repository (e.g. orphan or referenced by hidden ref)
|
||||
if _, err := git_model.GetLFSMetaObjectByOid(ctx, repo.ID, oid); err == nil {
|
||||
continue
|
||||
}
|
||||
incomingNewToRepoLFS += sz
|
||||
}
|
||||
}
|
||||
@ -880,7 +884,7 @@ func HookPreReceive(ctx *gitea_context.PrivateContext) {
|
||||
// 2) Repo (git) size limit when NOT counting LFS into repo size
|
||||
if repo.ShouldCheckRepoSize() && !setting.LFSSizeInRepoSize {
|
||||
limit := repo.GetActualSizeLimit()
|
||||
if limit > 0 && predictedGitAfter > limit {
|
||||
if limit > 0 && predictedGitAfter > limit && predictedGitAfter > currentGit {
|
||||
log.Warn("Forbidden: repository size limit exceeded: %s > %s for repo %-v",
|
||||
base.FileSize(predictedGitAfter),
|
||||
base.FileSize(limit),
|
||||
|
||||
@ -33,7 +33,6 @@ func Repos(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.repositories")
|
||||
ctx.Data["PageIsAdminRepositories"] = true
|
||||
|
||||
ctx.Data["EnableSizeLimit"] = setting.EnableSizeLimit
|
||||
ctx.Data["RepoSizeLimit"] = base.FileSize(setting.RepoSizeLimit)
|
||||
ctx.Data["LFSSizeLimit"] = base.FileSize(setting.LFSSizeLimit)
|
||||
ctx.Data["LFSSizeInRepoSize"] = setting.LFSSizeInRepoSize
|
||||
@ -62,14 +61,13 @@ func UpdateRepoPost(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.repositories")
|
||||
ctx.Data["PageIsAdminRepositories"] = true
|
||||
|
||||
repoSizeLimit, err := base.GetFileSize(form.RepoSizeLimit)
|
||||
|
||||
ctx.Data["EnableSizeLimit"] = form.EnableSizeLimit
|
||||
ctx.Data["RepoSizeLimit"] = form.RepoSizeLimit
|
||||
ctx.Data["LFSSizeLimit"] = form.LFSSizeLimit
|
||||
ctx.Data["LFSSizeInRepoSize"] = form.LFSSizeInRepoSize
|
||||
|
||||
repoSizeLimit, err := base.GetFileSize(form.RepoSizeLimit)
|
||||
if err != nil {
|
||||
ctx.Data["Err_Repo_Size_Limit"] = err.Error()
|
||||
ctx.Data["Err_Repo_Size_Limit"] = form.RepoSizeLimit
|
||||
explore.RenderRepoSearch(ctx, &explore.RepoSearchOptions{
|
||||
Private: true,
|
||||
PageSize: setting.UI.Admin.RepoPagingNum,
|
||||
@ -80,10 +78,8 @@ func UpdateRepoPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
lfsSizeLimit, err := base.GetFileSize(form.LFSSizeLimit)
|
||||
ctx.Data["LFSSizeLimit"] = form.LFSSizeLimit
|
||||
|
||||
if err != nil {
|
||||
ctx.Data["Err_LFS_Size_Limit"] = err.Error()
|
||||
ctx.Data["Err_LFS_Size_Limit"] = form.LFSSizeLimit
|
||||
explore.RenderRepoSearch(ctx, &explore.RepoSearchOptions{
|
||||
Private: true,
|
||||
PageSize: setting.UI.Admin.RepoPagingNum,
|
||||
@ -93,7 +89,7 @@ func UpdateRepoPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
err = setting.SaveGlobalRepositorySetting(form.EnableSizeLimit, repoSizeLimit, lfsSizeLimit, form.LFSSizeInRepoSize)
|
||||
err = setting.SaveGlobalRepositorySetting(repoSizeLimit, lfsSizeLimit, form.LFSSizeInRepoSize)
|
||||
if err != nil {
|
||||
ctx.Data["Err_Repo_Size_Save"] = err.Error()
|
||||
explore.RenderRepoSearch(ctx, &explore.RepoSearchOptions{
|
||||
|
||||
@ -142,13 +142,19 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
if ctx.Data["Err_Repo_Size_Limit"] != nil {
|
||||
ctx.RenderWithErr(ctx.Tr("admin.config.invalid_repo_size", ctx.Data["Err_Repo_Size_Limit"].(string)),
|
||||
ctx.RenderWithErr(ctx.Tr("admin.config.invalid_repo_size", ctx.Data["Err_Repo_Size_Limit"]),
|
||||
opts.TplName, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Data["Err_LFS_Size_Limit"] != nil {
|
||||
ctx.RenderWithErr(ctx.Tr("admin.config.invalid_lfs_size", ctx.Data["Err_LFS_Size_Limit"]),
|
||||
opts.TplName, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Data["Err_Repo_Size_Save"] != nil {
|
||||
ctx.RenderWithErr(ctx.Tr("admin.config.save_repo_size_setting_failed", ctx.Data["Err_Repo_Size_Save"].(string)),
|
||||
ctx.RenderWithErr(ctx.Tr("admin.config.save_repo_size_setting_failed", ctx.Data["Err_Repo_Size_Save"]),
|
||||
opts.TplName, nil)
|
||||
return
|
||||
}
|
||||
|
||||
@ -64,7 +64,8 @@ func SettingsCtxData(ctx *context.Context) {
|
||||
ctx.Data["Err_RepoSize"] = ctx.Repo.Repository.IsRepoSizeOversized(ctx.Repo.Repository.GetActualSizeLimit() / 10) // less than 10% left
|
||||
ctx.Data["ActualSizeLimit"] = ctx.Repo.Repository.GetActualSizeLimit()
|
||||
ctx.Data["ActualLFSSizeLimit"] = ctx.Repo.Repository.GetActualLFSSizeLimit()
|
||||
ctx.Data["EnableSizeLimit"] = setting.EnableSizeLimit
|
||||
ctx.Data["RepoSizeLimit"] = setting.RepoSizeLimit
|
||||
ctx.Data["LFSSizeLimit"] = setting.LFSSizeLimit
|
||||
ctx.Data["LFSSizeInRepoSize"] = setting.LFSSizeInRepoSize
|
||||
|
||||
signing, _ := gitrepo.GetSigningKey(ctx, ctx.Repo.Repository)
|
||||
@ -213,6 +214,8 @@ func handleSettingsPostUpdate(ctx *context.Context) {
|
||||
repo.Name = newRepoName
|
||||
repo.LowerName = strings.ToLower(newRepoName)
|
||||
repo.Description = form.Description
|
||||
ctx.Data["RepoSizeLimitText"] = form.RepoSizeLimit
|
||||
ctx.Data["LFSSizeLimitText"] = form.LFSSizeLimit
|
||||
repo.Website = form.Website
|
||||
repo.IsTemplate = form.Template
|
||||
|
||||
@ -222,13 +225,13 @@ func handleSettingsPostUpdate(ctx *context.Context) {
|
||||
repoSizeLimit, err = base.GetFileSize(form.RepoSizeLimit)
|
||||
if err != nil {
|
||||
ctx.Data["Err_RepoSizeLimit"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.form.invalid_repo_size_limit"), tplSettingsOptions, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.form.invalid_repo_size_limit_repo"), tplSettingsOptions, &form)
|
||||
return
|
||||
}
|
||||
}
|
||||
if repoSizeLimit < 0 {
|
||||
ctx.Data["Err_RepoSizeLimit"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.form.repo_size_limit_negative"), tplSettingsOptions, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.form.invalid_repo_size_limit_repo"), tplSettingsOptions, &form)
|
||||
return
|
||||
}
|
||||
|
||||
@ -245,13 +248,13 @@ func handleSettingsPostUpdate(ctx *context.Context) {
|
||||
lfsSizeLimit, err = base.GetFileSize(form.LFSSizeLimit)
|
||||
if err != nil {
|
||||
ctx.Data["Err_LFSSizeLimit"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.form.invalid_lfs_size_limit"), tplSettingsOptions, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.form.invalid_lfs_size_limit_repo"), tplSettingsOptions, &form)
|
||||
return
|
||||
}
|
||||
}
|
||||
if lfsSizeLimit < 0 {
|
||||
ctx.Data["Err_LFSSizeLimit"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.form.lfs_size_limit_negative"), tplSettingsOptions, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.form.invalid_lfs_size_limit_repo"), tplSettingsOptions, &form)
|
||||
return
|
||||
}
|
||||
if !ctx.Doer.IsAdmin && repo.LFSSizeLimit != lfsSizeLimit {
|
||||
|
||||
@ -22,7 +22,6 @@ import (
|
||||
type UpdateGlobalRepoFrom struct {
|
||||
RepoSizeLimit string
|
||||
LFSSizeLimit string
|
||||
EnableSizeLimit bool
|
||||
LFSSizeInRepoSize bool
|
||||
}
|
||||
|
||||
|
||||
@ -6,18 +6,6 @@
|
||||
<div class="ui attached segment">
|
||||
<form class="ui form" action="{{.Link}}" method="post">
|
||||
{{.CsrfTokenHtml}}
|
||||
<div class="inline field">
|
||||
<label>{{ctx.Locale.Tr "admin.config.enable_size_limit"}}</label>
|
||||
<div class="ui checkbox">
|
||||
<input name="enable_size_limit" type="checkbox" {{if .EnableSizeLimit}}checked{{end}}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label>{{ctx.Locale.Tr "admin.config.lfs_size_in_repo_size"}}</label>
|
||||
<div class="ui checkbox">
|
||||
<input name="lfs_size_in_repo_size" type="checkbox" {{if .LFSSizeInRepoSize}}checked{{end}} data-tooltip-content='{{ctx.Locale.Tr "admin.config.lfs_size_in_repo_size.desc"}}'>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inline field {{if .Err_Repo_Size_Limit}}error{{end}}">
|
||||
<label for="repo_size_limit">{{ctx.Locale.Tr "admin.config.repo_size_limit"}}</label>
|
||||
<input id="repo_size_limit" name="repo_size_limit" value="{{.RepoSizeLimit}}" data-tooltip-content='{{ctx.Locale.Tr "admin.config.repo_size_limit.desc"}}'>
|
||||
@ -26,6 +14,12 @@
|
||||
<label for="lfs_size_limit">{{ctx.Locale.Tr "admin.config.lfs_size_limit"}}</label>
|
||||
<input id="lfs_size_limit" name="lfs_size_limit" value="{{.LFSSizeLimit}}" data-tooltip-content='{{ctx.Locale.Tr "admin.config.lfs_size_limit.desc"}}'>
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label>{{ctx.Locale.Tr "admin.config.lfs_size_in_repo_size"}}</label>
|
||||
<div class="ui checkbox">
|
||||
<input name="lfs_size_in_repo_size" type="checkbox" {{if .LFSSizeInRepoSize}}checked{{end}} data-tooltip-content='{{ctx.Locale.Tr "admin.config.lfs_size_in_repo_size.desc"}}'>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<button class="ui green button">{{ctx.Locale.Tr "admin.config.update_settings"}}</button>
|
||||
</div>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
<div class="inline field">
|
||||
<label>{{ctx.Locale.Tr "repo.repo_size"}}</label>
|
||||
<span {{if .Err_RepoSize}}class="ui text red"{{end}} {{if not (eq .Repository.Size 0)}} data-tooltip-content="{{.Repository.SizeDetailsString}}"{{end}}>{{FileSize .Repository.Size}}
|
||||
{{if and .ActualSizeLimit .EnableSizeLimit}}
|
||||
{{if and .ActualSizeLimit (or (gt .RepoSizeLimit -1) (gt .LFSSizeLimit -1))}}
|
||||
/ {{FileSize .ActualSizeLimit}}
|
||||
{{end}}
|
||||
</span>
|
||||
@ -23,7 +23,7 @@
|
||||
<div class="inline field">
|
||||
<label>{{ctx.Locale.Tr "repo.lfs_size"}}</label>
|
||||
<span>{{FileSize .Repository.LFSSize}}
|
||||
{{if and .ActualLFSSizeLimit .EnableSizeLimit}}
|
||||
{{if and .ActualLFSSizeLimit (or (gt .RepoSizeLimit -1) (gt .LFSSizeLimit -1))}}
|
||||
/ {{FileSize .ActualLFSSizeLimit}}
|
||||
{{end}}
|
||||
</span>
|
||||
@ -31,14 +31,15 @@
|
||||
<div class="field {{if .Err_RepoSizeLimit}}error{{end}}" {{if not .IsAdmin}}style="display:none;"{{end}}>
|
||||
<label for="repo_size_limit">{{ctx.Locale.Tr "repo.repo_size_limit"}}</label>
|
||||
<input id="repo_size_limit" name="repo_size_limit"
|
||||
{{if not .EnableSizeLimit}}class="ui text light grey"{{end}}
|
||||
type="text" value="{{if .Repository.SizeLimit}}{{FileSize .Repository.SizeLimit}}{{end}}">
|
||||
{{if and (eq .RepoSizeLimit -1) (eq .LFSSizeLimit -1)}}class="ui text light grey"{{end}}
|
||||
type="text" value="{{if .RepoSizeLimitText}}{{.RepoSizeLimitText}}{{else if .Repository.SizeLimit}}{{FileSize .Repository.SizeLimit}}{{end}}"
|
||||
data-tooltip-content='{{ctx.Locale.Tr "repo.repo_size_limit_helper"}}'>
|
||||
</div>
|
||||
<div class="field {{if .Err_LFSSizeLimit}}error{{end}}" {{if not .IsAdmin}}style="display:none;"{{end}}>
|
||||
<label for="lfs_size_limit">{{ctx.Locale.Tr "repo.lfs_size_limit"}}</label>
|
||||
<input id="lfs_size_limit" name="lfs_size_limit"
|
||||
{{if not .EnableSizeLimit}}class="ui text light grey"{{end}}
|
||||
type="text" value="{{if .Repository.LFSSizeLimit}}{{FileSize .Repository.LFSSizeLimit}}{{end}}"
|
||||
{{if and (eq .RepoSizeLimit -1) (eq .LFSSizeLimit -1)}}class="ui text light grey"{{end}}
|
||||
type="text" value="{{if .LFSSizeLimitText}}{{.LFSSizeLimitText}}{{else if .Repository.LFSSizeLimit}}{{FileSize .Repository.LFSSizeLimit}}{{end}}"
|
||||
data-tooltip-content='{{ctx.Locale.Tr "repo.lfs_size_limit_helper"}}'>
|
||||
</div>
|
||||
<div class="inline field">
|
||||
|
||||
@ -87,7 +87,7 @@ func testGitGeneral(t *testing.T, u *url.URL) {
|
||||
|
||||
t.Run("SizeLimit", func(t *testing.T) {
|
||||
dstForkedPath := t.TempDir()
|
||||
setting.SaveGlobalRepositorySetting(true, 0, 0, false)
|
||||
setting.SaveGlobalRepositorySetting(0, 0, false)
|
||||
t.Run("Under", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
doCommitAndPush(t, testFileSizeSmall, dstPath, "data-file-")
|
||||
@ -115,7 +115,7 @@ func testGitGeneral(t *testing.T, u *url.URL) {
|
||||
doRebaseCommitAndPush(t, dstPath, lastCommitID)
|
||||
newRepoSize := doGetRemoteRepoSizeViaAPI(t, forkedUserCtx)
|
||||
assert.LessOrEqual(t, newRepoSize, oldRepoSize)
|
||||
setting.SaveGlobalRepositorySetting(false, 0, 0, false)
|
||||
setting.SaveGlobalRepositorySetting(-1, -1, false)
|
||||
})
|
||||
})
|
||||
t.Run("CreateAgitFlowPull", doCreateAgitFlowPull(dstPath, &httpContext, "test/head"))
|
||||
|
||||
@ -52,7 +52,7 @@ func ID5() string {
|
||||
//
|
||||
// Enable/disable via:
|
||||
//
|
||||
// setting.SaveGlobalRepositorySetting(enabled, repoLimit, lfsLimit, lfsSizeInRepoSize)
|
||||
// setting.SaveGlobalRepositorySetting(repoLimit, lfsLimit, lfsSizeInRepoSize)
|
||||
//
|
||||
// Scenarios:
|
||||
// - repo-only limit: blocks git blobs but not LFS objects (when lfsSizeInRepoSize=false, lfsLimit=0)
|
||||
@ -66,7 +66,7 @@ func TestLFSSizeLimit(t *testing.T) {
|
||||
func testLFSSizeLimit(t *testing.T, baseURL *url.URL) {
|
||||
// Always disable at the end so we don't leak to other integration tests.
|
||||
t.Cleanup(func() {
|
||||
setting.SaveGlobalRepositorySetting(false, 0, 0, false)
|
||||
setting.SaveGlobalRepositorySetting(-1, -1, false)
|
||||
})
|
||||
|
||||
if !setting.LFS.StartServer {
|
||||
@ -263,7 +263,7 @@ func testLFSSizeLimit(t *testing.T, baseURL *url.URL) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
// Global: repo limit ON, LFS limit OFF, LFS not counted into repo size.
|
||||
setting.SaveGlobalRepositorySetting(true, repoLimitBytes, 0, false)
|
||||
setting.SaveGlobalRepositorySetting(repoLimitBytes, 0, false)
|
||||
|
||||
ctx := newLimitRepo(t, "ggit")
|
||||
|
||||
@ -282,8 +282,7 @@ func testLFSSizeLimit(t *testing.T, baseURL *url.URL) {
|
||||
func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
// Per-repo: enable checking globally but do not set global limits.
|
||||
setting.SaveGlobalRepositorySetting(true, 0, 0, false)
|
||||
setting.SaveGlobalRepositorySetting(0, 0, false)
|
||||
|
||||
ctx := newLimitRepo(t, "rgit")
|
||||
|
||||
@ -310,7 +309,7 @@ func testLFSSizeLimit(t *testing.T, baseURL *url.URL) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
// Global: LFS limit ON, repo limit OFF, LFS not counted into repo size.
|
||||
setting.SaveGlobalRepositorySetting(true, 0, lfsLimitBytes, false)
|
||||
setting.SaveGlobalRepositorySetting(0, lfsLimitBytes, false)
|
||||
|
||||
ctx := newLimitRepo(t, "glfs")
|
||||
|
||||
@ -329,8 +328,7 @@ func testLFSSizeLimit(t *testing.T, baseURL *url.URL) {
|
||||
func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
// Per-repo: enable checking globally but do not set global limits.
|
||||
setting.SaveGlobalRepositorySetting(true, 0, 0, false)
|
||||
setting.SaveGlobalRepositorySetting(0, 0, false)
|
||||
|
||||
ctx := newLimitRepo(t, "rlfs")
|
||||
|
||||
@ -353,7 +351,7 @@ func testLFSSizeLimit(t *testing.T, baseURL *url.URL) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
// Global: repo limit ON, no LFS-specific limit, but LFS counted into repo size.
|
||||
setting.SaveGlobalRepositorySetting(true, combinedRepoLimitBytes, 0, true)
|
||||
setting.SaveGlobalRepositorySetting(combinedRepoLimitBytes, 0, true)
|
||||
|
||||
ctx := newLimitRepo(t, "gc")
|
||||
|
||||
@ -369,7 +367,7 @@ func testLFSSizeLimit(t *testing.T, baseURL *url.URL) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
// Per-repo: enable checking globally with LFSSizeInRepoSize=true but no global limits.
|
||||
setting.SaveGlobalRepositorySetting(true, 0, 0, true)
|
||||
setting.SaveGlobalRepositorySetting(0, 0, true)
|
||||
|
||||
ctx := newLimitRepo(t, "rc")
|
||||
|
||||
@ -390,7 +388,7 @@ func testLFSSizeLimit(t *testing.T, baseURL *url.URL) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
// Global: strict LFS limit, no repo limit.
|
||||
setting.SaveGlobalRepositorySetting(true, 0, lfsLimitBytes, false)
|
||||
setting.SaveGlobalRepositorySetting(-1, lfsLimitBytes, false)
|
||||
|
||||
ctx := newLimitRepo(t, "rwing")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user