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()
|
||||
|
||||
@@ -153,10 +153,6 @@ type CreateRepoOption struct {
|
||||
// ObjectFormatName of the underlying git repository
|
||||
// enum: sha1,sha256
|
||||
ObjectFormatName string `json:"object_format_name" binding:"MaxSize(6)"`
|
||||
// SizeLimit of the repository
|
||||
SizeLimit int64 `json:"size_limit"`
|
||||
// LFSSizeLimit of the repository
|
||||
LFSSizeLimit int64 `json:"lfs_size_limit"`
|
||||
}
|
||||
|
||||
// EditRepoOption options when editing a repository's properties
|
||||
@@ -227,11 +223,7 @@ type EditRepoOption struct {
|
||||
DefaultAllowMaintainerEdit *bool `json:"default_allow_maintainer_edit,omitempty"`
|
||||
// set to `true` to archive this repository.
|
||||
Archived *bool `json:"archived,omitempty"`
|
||||
// SizeLimit of the repository.
|
||||
SizeLimit *int64 `json:"size_limit,omitempty"`
|
||||
// LFSSizeLimit of the repository.
|
||||
LFSSizeLimit *int64 `json:"lfs_size_limit,omitempty"`
|
||||
// set to a string like `8h30m0s` to set the mirror interval time
|
||||
// set a string like `8h30m0s` to set the mirror interval time
|
||||
MirrorInterval *string `json:"mirror_interval,omitempty"`
|
||||
// enable prune - remove obsolete remote-tracking references when mirroring
|
||||
EnablePrune *bool `json:"enable_prune,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user