mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-20 18:49:34 +02:00
SizeLimit w/o DB changes
This commit is contained in:
@@ -6,7 +6,6 @@ package setting
|
||||
import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
@@ -56,6 +55,8 @@ var (
|
||||
DisableDownloadSourceArchives bool
|
||||
AllowForkWithoutMaximumLimit bool
|
||||
AllowForkIntoSameOwner bool
|
||||
GitSizeMax int64 `ini:"GIT_SIZE_MAX"`
|
||||
LFSSizeMax int64 `ini:"LFS_SIZE_MAX"`
|
||||
|
||||
// StreamArchives makes Gitea stream git archive files to the client directly instead of creating an archive first.
|
||||
// Ideally all users should use this streaming method. However, at the moment we don't know whether there are
|
||||
@@ -276,36 +277,11 @@ var (
|
||||
}
|
||||
RepoRootPath string
|
||||
ScriptType = "bash"
|
||||
|
||||
// Repository size limits
|
||||
RepoSizeLimit int64 = -1
|
||||
LFSSizeLimit int64 = -1
|
||||
LFSSizeInRepoSize bool
|
||||
)
|
||||
|
||||
func SaveGlobalRepositorySetting(repoSizeLimit, lfsSizeLimit int64, lfsSizeInRepoSize bool) error {
|
||||
RepoSizeLimit = repoSizeLimit
|
||||
LFSSizeLimit = lfsSizeLimit
|
||||
LFSSizeInRepoSize = lfsSizeInRepoSize
|
||||
|
||||
cfg, err := CfgProvider.PrepareSaving()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sec := cfg.Section("repository")
|
||||
if RepoSizeLimit == -1 {
|
||||
sec.Key("REPO_SIZE_LIMIT").SetValue("-1")
|
||||
} else {
|
||||
sec.Key("REPO_SIZE_LIMIT").SetValue(humanize.Bytes(uint64(RepoSizeLimit)))
|
||||
}
|
||||
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 UpdateGlobalRepositoryLimit(gitSizeMax, lfsSizeMax int64) {
|
||||
Repository.GitSizeMax = gitSizeMax
|
||||
Repository.LFSSizeMax = lfsSizeMax
|
||||
}
|
||||
|
||||
func parseSize(sec ConfigSection, key string, def int64) int64 {
|
||||
@@ -328,9 +304,8 @@ func loadRepositoryFrom(rootCfg ConfigProvider) {
|
||||
|
||||
// Determine and create root git repository path.
|
||||
sec := rootCfg.Section("repository")
|
||||
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.GitSizeMax = parseSize(sec, "GIT_SIZE_MAX", -1)
|
||||
Repository.LFSSizeMax = parseSize(sec, "LFS_SIZE_MAX", -1)
|
||||
|
||||
Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
|
||||
Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool()
|
||||
|
||||
Reference in New Issue
Block a user