mirror of
https://github.com/go-gitea/gitea.git
synced 2026-06-12 11:32:32 +02:00
Overall Done for Global Repo Size Limit Option
This commit is contained in:
parent
66c476e5de
commit
d843a6736b
@ -162,8 +162,8 @@ type Repository struct {
|
||||
BaseRepo *Repository `xorm:"-"`
|
||||
IsTemplate bool `xorm:"INDEX NOT NULL DEFAULT false"`
|
||||
TemplateID int64 `xorm:"INDEX"`
|
||||
Size int64 `xorm:"NOT NULL DEFAULT 0"`
|
||||
SizeLimit int64 `xorm:"NOT NULL DEFAULT 0"`
|
||||
Size int64 `xorm:"NOT NULL DEFAULT 0"`
|
||||
EnableSizeLimit bool `xorm:"NOT NULL DEFAULT true"`
|
||||
CodeIndexerStatus *RepoIndexerStatus `xorm:"-"`
|
||||
StatsIndexerStatus *RepoIndexerStatus `xorm:"-"`
|
||||
@ -538,9 +538,17 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
|
||||
// return repo.updateSize(ctx.e)
|
||||
// }
|
||||
|
||||
func (repo *Repository) GetActualSizeLimit() int64 {
|
||||
sizeLimit := repo.SizeLimit
|
||||
if setting.RepoSizeLimit > 0 && sizeLimit == 0 {
|
||||
sizeLimit = setting.RepoSizeLimit
|
||||
}
|
||||
return sizeLimit
|
||||
}
|
||||
|
||||
// RepoSizeIsOversized return if is over size limitation
|
||||
func (repo *Repository) RepoSizeIsOversized(additionalSize int64) bool {
|
||||
return repo.SizeLimit > 0 && repo.Size+additionalSize > repo.SizeLimit
|
||||
return setting.EnableSizeLimit && repo.GetActualSizeLimit() > 0 && repo.Size+additionalSize > repo.GetActualSizeLimit()
|
||||
}
|
||||
|
||||
// CanCreateBranch returns true if repository meets the requirements for creating new branches.
|
||||
|
||||
@ -289,8 +289,8 @@ func loadRepositoryFrom(rootCfg ConfigProvider) {
|
||||
|
||||
// Determine and create root git repository path.
|
||||
sec := rootCfg.Section("repository")
|
||||
EnableSizeLimit = sec.Key("ENABLE_SIZE_LIMIT").MustBool()
|
||||
RepoSizeLimit = sec.Key("REPO_SIZE_LIMIT").MustInt64(0)
|
||||
EnableSizeLimit = sec.Key("ENABLE_SIZE_LIMIT").MustBool(true)
|
||||
RepoSizeLimit = sec.Key("REPO_SIZE_LIMIT").MustInt64(1024 * 1024 * 10)
|
||||
Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
|
||||
Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool()
|
||||
Repository.MaxCreationLimit = sec.Key("MAX_CREATION_LIMIT").MustInt(-1)
|
||||
|
||||
@ -3009,6 +3009,12 @@ config.picture_service = Picture Service
|
||||
config.disable_gravatar = Disable Gravatar
|
||||
config.enable_federated_avatar = Enable Federated Avatars
|
||||
|
||||
config.repository_config = Repository Configuration
|
||||
config.enable_size_limit = Enable Size Limit
|
||||
config.repo_size_limit = Default Repository Size Limit
|
||||
config.invalid_repo_size = Invalid repository size.
|
||||
config.repository_setting_success = Global repository setting has been updated.
|
||||
|
||||
config.git_config = Git Configuration
|
||||
config.git_disable_diff_highlight = Disable Diff Syntax Highlight
|
||||
config.git_max_diff_lines = Max Diff Lines (for a single file)
|
||||
|
||||
@ -66,9 +66,6 @@ func UpdateRepoPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
setting.SaveGlobalRepositorySetting(form.EnableSizeLimit, repo_size_limit)
|
||||
ctx.Flash.Success(ctx.Tr("admin.config.repository_setting_success"))
|
||||
|
||||
ctx.Data["RepoSizeLimit"] = base.FileSize(setting.RepoSizeLimit)
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("admin.config.repository_setting_success"))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/repos")
|
||||
|
||||
@ -67,7 +67,9 @@ func SettingsCtxData(ctx *context.Context) {
|
||||
ctx.Data["DisableNewPushMirrors"] = setting.Mirror.DisableNewPush
|
||||
ctx.Data["DefaultMirrorInterval"] = setting.Mirror.DefaultInterval
|
||||
ctx.Data["MinimumMirrorInterval"] = setting.Mirror.MinInterval
|
||||
ctx.Data["Err_RepoSize"] = ctx.Repo.Repository.RepoSizeIsOversized(ctx.Repo.Repository.SizeLimit / 10) // less than 10% left
|
||||
ctx.Data["Err_RepoSize"] = ctx.Repo.Repository.RepoSizeIsOversized(ctx.Repo.Repository.GetActualSizeLimit() / 10) // less than 10% left
|
||||
ctx.Data["ActualSizeLimit"] = ctx.Repo.Repository.GetActualSizeLimit()
|
||||
ctx.Data["EnableSizeLimit"] = setting.EnableSizeLimit
|
||||
|
||||
signing, _ := asymkey_service.SigningKey(ctx, ctx.Repo.Repository.RepoPath())
|
||||
ctx.Data["SigningKeyAvailable"] = len(signing) > 0
|
||||
|
||||
@ -13,14 +13,18 @@
|
||||
<input id="repo_name" name="repo_name" value="{{.Repository.Name}}" data-repo-name="{{.Repository.Name}}" autofocus required>
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label>{{.i18n.Tr "repo.repo_size"}}</label>
|
||||
<span {{if .Err_RepoSize}}class="ui text red"{{end}}>{{FileSize .Repository.Size}}{{if .Repository.SizeLimit}}/{{FileSize .Repository.SizeLimit}}{{end}}</span>
|
||||
<label>{{.locale.Tr "repo.repo_size"}}</label>
|
||||
<span {{if .Err_RepoSize}}class="ui text red"{{end}}>{{FileSize .Repository.Size}}
|
||||
{{if and .Repository.SizeLimit .EnableSizeLimit}}
|
||||
/{{FileSize .ActualSizeLimit}}
|
||||
{{end}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="field {{if .Err_RepoSizeLimit}}error{{end}}" {{if not .IsAdmin}}style="display:none;"{{end}}>
|
||||
<label for="repo_size_limit">{{.locale.Tr "repo.repo_size_limit"}}</label>
|
||||
<input id="repo_size_limit" name="repo_size_limit" type="number" value="{{.Repository.SizeLimit}}" data-repo-size-limit="{{.Repository.SizeLimit}}">
|
||||
<label>{{.locale.Tr "repo.repo_size"}}</label>
|
||||
<span>{{FileSize .Repository.Size}}</span>
|
||||
<input id="repo_size_limit" name="repo_size_limit"
|
||||
{{if .EnableSizeLimit}}class="ui text light grey"{{end}}
|
||||
type="number" value="{{.Repository.SizeLimit}}" data-repo-size-limit="{{.Repository.SizeLimit}}">
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label>{{.locale.Tr "repo.template"}}</label>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user