From f9b26b80c11a007c0fb2ad247d86599263d6f56c Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sat, 21 Feb 2026 15:51:35 +0100 Subject: [PATCH 1/9] fix broken ipv6 layout for acme https://github.com/go-gitea/gitea/issues/31638 --- cmd/web_acme.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/web_acme.go b/cmd/web_acme.go index 5f7a3083349ca..150b1248562c3 100644 --- a/cmd/web_acme.go +++ b/cmd/web_acme.go @@ -7,6 +7,7 @@ import ( "crypto/x509" "encoding/pem" "fmt" + "net" "net/http" "os" "strconv" @@ -125,7 +126,8 @@ func runACME(listenAddr string, m http.Handler) error { log.Info("Running Let's Encrypt handler on %s", setting.HTTPAddr+":"+setting.PortToRedirect) // all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validation happens here) - err := runHTTP("tcp", setting.HTTPAddr+":"+setting.PortToRedirect, "Let's Encrypt HTTP Challenge", myACME.HTTPChallengeHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)), setting.RedirectorUseProxyProtocol) + + err := runHTTP("tcp", net.JoinHostPort(setting.HTTPAddr,setting.PortToRedirect), "Let's Encrypt HTTP Challenge", myACME.HTTPChallengeHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)), setting.RedirectorUseProxyProtocol) if err != nil { log.Fatal("Failed to start the Let's Encrypt handler on port %s: %v", setting.PortToRedirect, err) } From 0b6362498ca71da06aea0906999622987bbb5727 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sat, 21 Feb 2026 17:09:44 +0100 Subject: [PATCH 2/9] introduce new settings for release attachments --- modules/setting/attachment.go | 22 ++++++++++++++-------- routers/api/v1/repo/release_attachment.go | 2 +- routers/web/repo/attachment.go | 4 ++-- services/attachment/attachment.go | 3 +++ services/context/upload/upload.go | 4 ++-- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/modules/setting/attachment.go b/modules/setting/attachment.go index 5d420c987cb3d..5370424bc80ba 100644 --- a/modules/setting/attachment.go +++ b/modules/setting/attachment.go @@ -4,11 +4,13 @@ package setting type AttachmentSettingType struct { - Storage *Storage - AllowedTypes string - MaxSize int64 - MaxFiles int - Enabled bool + Storage *Storage + AllowedTypes string + MaxSize int64 + ReleaseMaxFileSize int64 + MaxFiles int + ReleaseMaxFiles int + Enabled bool } var Attachment AttachmentSettingType @@ -19,10 +21,12 @@ func loadAttachmentFrom(rootCfg ConfigProvider) (err error) { // FIXME: this size is used for both "issue attachment" and "release attachment" // The design is not right, these two should be different settings - MaxSize: 2048, + MaxSize: 2048, + ReleaseMaxFileSize: 2048, - MaxFiles: 5, - Enabled: true, + MaxFiles: 5, + ReleaseMaxFiles: 5, + Enabled: true, } sec, _ := rootCfg.GetSection("attachment") if sec == nil { @@ -32,7 +36,9 @@ func loadAttachmentFrom(rootCfg ConfigProvider) (err error) { Attachment.AllowedTypes = sec.Key("ALLOWED_TYPES").MustString(Attachment.AllowedTypes) Attachment.MaxSize = sec.Key("MAX_SIZE").MustInt64(Attachment.MaxSize) + Attachment.MaxSize = sec.Key("RELEASE_MAX_SIZE").MustInt64(Attachment.MaxSize) Attachment.MaxFiles = sec.Key("MAX_FILES").MustInt(Attachment.MaxFiles) + Attachment.MaxFiles = sec.Key("RELEASE_MAX_FILES").MustInt(Attachment.MaxFiles) Attachment.Enabled = sec.Key("ENABLED").MustBool(Attachment.Enabled) Attachment.Storage, err = getStorage(rootCfg, "attachments", "", sec) return err diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go index 5f5423fafeded..33f012523b236 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -234,7 +234,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) { } // Create a new attachment and save the file - attach, err := attachment_service.UploadAttachmentGeneralSizeLimit(ctx, uploaderFile, setting.Repository.Release.AllowedTypes, &repo_model.Attachment{ + attach, err := attachment_service.UploadAttachmentReleaseSizeLimit(ctx, uploaderFile, setting.Repository.Release.AllowedTypes, &repo_model.Attachment{ Name: filename, UploaderID: ctx.Doer.ID, RepoID: ctx.Repo.Repository.ID, diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go index bc14e4254329c..a83f0f40ec81f 100644 --- a/routers/web/repo/attachment.go +++ b/routers/web/repo/attachment.go @@ -46,7 +46,7 @@ func uploadAttachment(ctx *context.Context, repoID int64, allowedTypes string) { defer file.Close() uploaderFile := attachment.NewLimitedUploaderKnownSize(file, header.Size) - attach, err := attachment.UploadAttachmentGeneralSizeLimit(ctx, uploaderFile, allowedTypes, &repo_model.Attachment{ + attach, err := attachment.UploadAttachmentReleaseSizeLimit(ctx, uploaderFile, allowedTypes, &repo_model.Attachment{ Name: header.Filename, UploaderID: ctx.Doer.ID, RepoID: repoID, @@ -56,7 +56,7 @@ func uploadAttachment(ctx *context.Context, repoID int64, allowedTypes string) { ctx.HTTPError(http.StatusBadRequest, err.Error()) return } - ctx.ServerError("UploadAttachmentGeneralSizeLimit", err) + ctx.ServerError("UploadAttachmentReleaseSizeLimit", err) return } diff --git a/services/attachment/attachment.go b/services/attachment/attachment.go index eb208a141cb32..d9652f81b107a 100644 --- a/services/attachment/attachment.go +++ b/services/attachment/attachment.go @@ -57,6 +57,9 @@ func NewLimitedUploaderMaxBytesReader(r io.ReadCloser, w http.ResponseWriter) *U func UploadAttachmentGeneralSizeLimit(ctx context.Context, file *UploaderFile, allowedTypes string, attach *repo_model.Attachment) (*repo_model.Attachment, error) { return uploadAttachment(ctx, file, allowedTypes, setting.Attachment.MaxSize<<20, attach) } +func UploadAttachmentReleaseSizeLimit(ctx context.Context, file *UploaderFile, allowedTypes string, attach *repo_model.Attachment) (*repo_model.Attachment, error) { + return uploadAttachment(ctx, file, allowedTypes, setting.Attachment.ReleaseMaxFileSize<<20, attach) +} func uploadAttachment(ctx context.Context, file *UploaderFile, allowedTypes string, maxFileSize int64, attach *repo_model.Attachment) (*repo_model.Attachment, error) { src := file.rd diff --git a/services/context/upload/upload.go b/services/context/upload/upload.go index 23707950d4a5c..bb71e864f5dfc 100644 --- a/services/context/upload/upload.go +++ b/services/context/upload/upload.go @@ -95,8 +95,8 @@ func AddUploadContext(ctx *context.Context, uploadType string) { ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/releases/attachments/remove" ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/releases/attachments" ctx.Data["UploadAccepts"] = strings.ReplaceAll(setting.Repository.Release.AllowedTypes, "|", ",") - ctx.Data["UploadMaxFiles"] = setting.Attachment.MaxFiles - ctx.Data["UploadMaxSize"] = setting.Attachment.MaxSize + ctx.Data["UploadMaxFiles"] = setting.Attachment.ReleaseMaxFiles + ctx.Data["UploadMaxSize"] = setting.Attachment.ReleaseMaxFileSize case "comment": ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/issues/attachments" ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/issues/attachments/remove" From 26e2f7a8f8054328d4c64f8c4d46cfffe30ac938 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sat, 21 Feb 2026 17:24:16 +0100 Subject: [PATCH 3/9] formatting --- cmd/web_acme.go | 2 +- services/attachment/attachment.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/web_acme.go b/cmd/web_acme.go index 150b1248562c3..fce341dc0ab8c 100644 --- a/cmd/web_acme.go +++ b/cmd/web_acme.go @@ -127,7 +127,7 @@ func runACME(listenAddr string, m http.Handler) error { log.Info("Running Let's Encrypt handler on %s", setting.HTTPAddr+":"+setting.PortToRedirect) // all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validation happens here) - err := runHTTP("tcp", net.JoinHostPort(setting.HTTPAddr,setting.PortToRedirect), "Let's Encrypt HTTP Challenge", myACME.HTTPChallengeHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)), setting.RedirectorUseProxyProtocol) + err := runHTTP("tcp", net.JoinHostPort(setting.HTTPAddr, setting.PortToRedirect), "Let's Encrypt HTTP Challenge", myACME.HTTPChallengeHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)), setting.RedirectorUseProxyProtocol) if err != nil { log.Fatal("Failed to start the Let's Encrypt handler on port %s: %v", setting.PortToRedirect, err) } diff --git a/services/attachment/attachment.go b/services/attachment/attachment.go index d9652f81b107a..ae7100d85b577 100644 --- a/services/attachment/attachment.go +++ b/services/attachment/attachment.go @@ -57,6 +57,7 @@ func NewLimitedUploaderMaxBytesReader(r io.ReadCloser, w http.ResponseWriter) *U func UploadAttachmentGeneralSizeLimit(ctx context.Context, file *UploaderFile, allowedTypes string, attach *repo_model.Attachment) (*repo_model.Attachment, error) { return uploadAttachment(ctx, file, allowedTypes, setting.Attachment.MaxSize<<20, attach) } + func UploadAttachmentReleaseSizeLimit(ctx context.Context, file *UploaderFile, allowedTypes string, attach *repo_model.Attachment) (*repo_model.Attachment, error) { return uploadAttachment(ctx, file, allowedTypes, setting.Attachment.ReleaseMaxFileSize<<20, attach) } From 5ca08f7635fdeefc7c4c5a005a2393dec9a9a8ed Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sat, 21 Feb 2026 18:41:54 +0100 Subject: [PATCH 4/9] update setting used in test --- tests/integration/api_releases_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go index b3b30a33d5ebf..e39e5793c06e7 100644 --- a/tests/integration/api_releases_test.go +++ b/tests/integration/api_releases_test.go @@ -335,7 +335,7 @@ func TestAPIDeleteReleaseByTagName(t *testing.T) { func TestAPIUploadAssetRelease(t *testing.T) { defer tests.PrepareTestEnv(t)() - defer test.MockVariableValue(&setting.Attachment.MaxSize, 1)() + defer test.MockVariableValue(&setting.Attachment.ReleaseMaxFileSize, 1)() repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) From 752147d210fa9514d79cf91e74bb4eb79cb4603f Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sat, 21 Feb 2026 20:21:52 +0100 Subject: [PATCH 5/9] move setting to repository.release section --- cmd/web_acme.go | 3 +-- custom/conf/app.example.ini | 3 ++- modules/setting/attachment.go | 26 ++++++++------------------ modules/setting/repository.go | 6 ++++++ services/attachment/attachment.go | 2 +- services/context/upload/upload.go | 4 ++-- tests/integration/api_releases_test.go | 2 +- 7 files changed, 21 insertions(+), 25 deletions(-) diff --git a/cmd/web_acme.go b/cmd/web_acme.go index fce341dc0ab8c..a2e14638f8c07 100644 --- a/cmd/web_acme.go +++ b/cmd/web_acme.go @@ -125,8 +125,7 @@ func runACME(listenAddr string, m http.Handler) error { defer finished() log.Info("Running Let's Encrypt handler on %s", setting.HTTPAddr+":"+setting.PortToRedirect) - // all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validation happens here) - + // all traffic coming into HTTP will be redirected to HTTPS automatically (LE HTTP-01 validation happens here) err := runHTTP("tcp", net.JoinHostPort(setting.HTTPAddr, setting.PortToRedirect), "Let's Encrypt HTTP Challenge", myACME.HTTPChallengeHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)), setting.RedirectorUseProxyProtocol) if err != nil { log.Fatal("Failed to start the Let's Encrypt handler on port %s: %v", setting.PortToRedirect, err) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index c7f8401cd92b2..c26ea8e2baa66 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1181,7 +1181,8 @@ LEVEL = Info ;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types. ;ALLOWED_TYPES = ;DEFAULT_PAGING_NUM = 10 - +;MAX_FILE_SIZE = 2048 +;MAX_FILES = 5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;[repository.signing] diff --git a/modules/setting/attachment.go b/modules/setting/attachment.go index 5370424bc80ba..c11b0c478ae56 100644 --- a/modules/setting/attachment.go +++ b/modules/setting/attachment.go @@ -4,13 +4,11 @@ package setting type AttachmentSettingType struct { - Storage *Storage - AllowedTypes string - MaxSize int64 - ReleaseMaxFileSize int64 - MaxFiles int - ReleaseMaxFiles int - Enabled bool + Storage *Storage + AllowedTypes string + MaxSize int64 + MaxFiles int + Enabled bool } var Attachment AttachmentSettingType @@ -18,15 +16,9 @@ var Attachment AttachmentSettingType func loadAttachmentFrom(rootCfg ConfigProvider) (err error) { Attachment = AttachmentSettingType{ AllowedTypes: ".avif,.cpuprofile,.csv,.dmp,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.json,.jsonc,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.webp,.xls,.xlsx,.zip", - - // FIXME: this size is used for both "issue attachment" and "release attachment" - // The design is not right, these two should be different settings - MaxSize: 2048, - ReleaseMaxFileSize: 2048, - - MaxFiles: 5, - ReleaseMaxFiles: 5, - Enabled: true, + MaxSize: 2048, + MaxFiles: 5, + Enabled: true, } sec, _ := rootCfg.GetSection("attachment") if sec == nil { @@ -36,9 +28,7 @@ func loadAttachmentFrom(rootCfg ConfigProvider) (err error) { Attachment.AllowedTypes = sec.Key("ALLOWED_TYPES").MustString(Attachment.AllowedTypes) Attachment.MaxSize = sec.Key("MAX_SIZE").MustInt64(Attachment.MaxSize) - Attachment.MaxSize = sec.Key("RELEASE_MAX_SIZE").MustInt64(Attachment.MaxSize) Attachment.MaxFiles = sec.Key("MAX_FILES").MustInt(Attachment.MaxFiles) - Attachment.MaxFiles = sec.Key("RELEASE_MAX_FILES").MustInt(Attachment.MaxFiles) Attachment.Enabled = sec.Key("ENABLED").MustBool(Attachment.Enabled) Attachment.Storage, err = getStorage(rootCfg, "attachments", "", sec) return err diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 90c4f22ad2e3f..9f0a209b537f9 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -100,6 +100,8 @@ var ( Release struct { AllowedTypes string DefaultPagingNum int + MaxFileSize int64 + MaxFiles int64 } `ini:"repository.release"` Signing struct { @@ -241,9 +243,13 @@ var ( Release: struct { AllowedTypes string DefaultPagingNum int + MaxFileSize int64 + MaxFiles int64 }{ AllowedTypes: "", DefaultPagingNum: 10, + MaxFileSize: 2048, // Same defaults as attachment + MaxFiles: 5, }, // Signing settings diff --git a/services/attachment/attachment.go b/services/attachment/attachment.go index ae7100d85b577..ee5f39dd9a455 100644 --- a/services/attachment/attachment.go +++ b/services/attachment/attachment.go @@ -59,7 +59,7 @@ func UploadAttachmentGeneralSizeLimit(ctx context.Context, file *UploaderFile, a } func UploadAttachmentReleaseSizeLimit(ctx context.Context, file *UploaderFile, allowedTypes string, attach *repo_model.Attachment) (*repo_model.Attachment, error) { - return uploadAttachment(ctx, file, allowedTypes, setting.Attachment.ReleaseMaxFileSize<<20, attach) + return uploadAttachment(ctx, file, allowedTypes, setting.Repository.Release.MaxFileSize<<20, attach) } func uploadAttachment(ctx context.Context, file *UploaderFile, allowedTypes string, maxFileSize int64, attach *repo_model.Attachment) (*repo_model.Attachment, error) { diff --git a/services/context/upload/upload.go b/services/context/upload/upload.go index bb71e864f5dfc..d770262b3c97a 100644 --- a/services/context/upload/upload.go +++ b/services/context/upload/upload.go @@ -95,8 +95,8 @@ func AddUploadContext(ctx *context.Context, uploadType string) { ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/releases/attachments/remove" ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/releases/attachments" ctx.Data["UploadAccepts"] = strings.ReplaceAll(setting.Repository.Release.AllowedTypes, "|", ",") - ctx.Data["UploadMaxFiles"] = setting.Attachment.ReleaseMaxFiles - ctx.Data["UploadMaxSize"] = setting.Attachment.ReleaseMaxFileSize + ctx.Data["UploadMaxFiles"] = setting.Repository.Release.MaxFiles + ctx.Data["UploadMaxSize"] = setting.Repository.Release.MaxFileSize case "comment": ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/issues/attachments" ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/issues/attachments/remove" diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go index e39e5793c06e7..2a1bb56087b4d 100644 --- a/tests/integration/api_releases_test.go +++ b/tests/integration/api_releases_test.go @@ -335,7 +335,7 @@ func TestAPIDeleteReleaseByTagName(t *testing.T) { func TestAPIUploadAssetRelease(t *testing.T) { defer tests.PrepareTestEnv(t)() - defer test.MockVariableValue(&setting.Attachment.ReleaseMaxFileSize, 1)() + defer test.MockVariableValue(&setting.Repository.Release.MaxFileSize, 1)() repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) From fcb99fbf894ca37ae82599cfa80b97e4d653bb83 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sat, 21 Feb 2026 20:38:17 +0100 Subject: [PATCH 6/9] sync naming styles --- custom/conf/app.example.ini | 2 +- modules/setting/repository.go | 6 +++--- services/attachment/attachment.go | 2 +- services/context/upload/upload.go | 2 +- tests/integration/api_releases_test.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index c26ea8e2baa66..6d62071cb89f8 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1181,7 +1181,7 @@ LEVEL = Info ;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types. ;ALLOWED_TYPES = ;DEFAULT_PAGING_NUM = 10 -;MAX_FILE_SIZE = 2048 +;FILE_MAX_SIZE = 2048 ;MAX_FILES = 5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 9f0a209b537f9..fca696f010288 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -100,7 +100,7 @@ var ( Release struct { AllowedTypes string DefaultPagingNum int - MaxFileSize int64 + FileMaxSize int64 MaxFiles int64 } `ini:"repository.release"` @@ -243,12 +243,12 @@ var ( Release: struct { AllowedTypes string DefaultPagingNum int - MaxFileSize int64 + FileMaxSize int64 MaxFiles int64 }{ AllowedTypes: "", DefaultPagingNum: 10, - MaxFileSize: 2048, // Same defaults as attachment + FileMaxSize: 2048, // Same defaults as attachment MaxFiles: 5, }, diff --git a/services/attachment/attachment.go b/services/attachment/attachment.go index ee5f39dd9a455..d69253dd5977e 100644 --- a/services/attachment/attachment.go +++ b/services/attachment/attachment.go @@ -59,7 +59,7 @@ func UploadAttachmentGeneralSizeLimit(ctx context.Context, file *UploaderFile, a } func UploadAttachmentReleaseSizeLimit(ctx context.Context, file *UploaderFile, allowedTypes string, attach *repo_model.Attachment) (*repo_model.Attachment, error) { - return uploadAttachment(ctx, file, allowedTypes, setting.Repository.Release.MaxFileSize<<20, attach) + return uploadAttachment(ctx, file, allowedTypes, setting.Repository.Release.FileMaxSize<<20, attach) } func uploadAttachment(ctx context.Context, file *UploaderFile, allowedTypes string, maxFileSize int64, attach *repo_model.Attachment) (*repo_model.Attachment, error) { diff --git a/services/context/upload/upload.go b/services/context/upload/upload.go index d770262b3c97a..3352bfa388f34 100644 --- a/services/context/upload/upload.go +++ b/services/context/upload/upload.go @@ -96,7 +96,7 @@ func AddUploadContext(ctx *context.Context, uploadType string) { ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/releases/attachments" ctx.Data["UploadAccepts"] = strings.ReplaceAll(setting.Repository.Release.AllowedTypes, "|", ",") ctx.Data["UploadMaxFiles"] = setting.Repository.Release.MaxFiles - ctx.Data["UploadMaxSize"] = setting.Repository.Release.MaxFileSize + ctx.Data["UploadMaxSize"] = setting.Repository.Release.FileMaxSize case "comment": ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/issues/attachments" ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/issues/attachments/remove" diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go index 2a1bb56087b4d..440209c644003 100644 --- a/tests/integration/api_releases_test.go +++ b/tests/integration/api_releases_test.go @@ -335,7 +335,7 @@ func TestAPIDeleteReleaseByTagName(t *testing.T) { func TestAPIUploadAssetRelease(t *testing.T) { defer tests.PrepareTestEnv(t)() - defer test.MockVariableValue(&setting.Repository.Release.MaxFileSize, 1)() + defer test.MockVariableValue(&setting.Repository.Release.FileMaxSize, 1)() repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) From 821875102308096931d7034c5089a2d5e4c1335b Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 22 Feb 2026 03:57:48 +0800 Subject: [PATCH 7/9] Update custom/conf/app.example.ini Signed-off-by: wxiaoguang --- custom/conf/app.example.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 6d62071cb89f8..84c904f17f462 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1183,6 +1183,7 @@ LEVEL = Info ;DEFAULT_PAGING_NUM = 10 ;FILE_MAX_SIZE = 2048 ;MAX_FILES = 5 + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;[repository.signing] From a4de68f0396f6d94ba7f2252e81ad102ad325563 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sat, 21 Feb 2026 22:17:18 +0100 Subject: [PATCH 8/9] reduce default attachment size expanded docs for release settings --- custom/conf/app.example.ini | 10 ++++++++-- modules/setting/attachment.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 84c904f17f462..4e452596878a0 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1180,8 +1180,14 @@ LEVEL = Info ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types. ;ALLOWED_TYPES = +;; +;; Number of releases that are displayed on release page ;DEFAULT_PAGING_NUM = 10 +;; +;; Max size of each file in megabytes. Defaults to 2GB ;FILE_MAX_SIZE = 2048 +;; +;; Max number of files per upload. Defaults to 5 ;MAX_FILES = 5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1997,8 +2003,8 @@ LEVEL = Info ;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types. ;ALLOWED_TYPES = .avif,.cpuprofile,.csv,.dmp,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.json,.jsonc,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.webp,.xls,.xlsx,.zip ;; -;; Max size of each file. Defaults to 2048MB -;MAX_SIZE = 2048 +;; Max size of each file. Defaults to 100MB +;MAX_SIZE = 100 ;; ;; Max number of files per upload. Defaults to 5 ;MAX_FILES = 5 diff --git a/modules/setting/attachment.go b/modules/setting/attachment.go index c11b0c478ae56..30e5cfbff1dff 100644 --- a/modules/setting/attachment.go +++ b/modules/setting/attachment.go @@ -16,7 +16,7 @@ var Attachment AttachmentSettingType func loadAttachmentFrom(rootCfg ConfigProvider) (err error) { Attachment = AttachmentSettingType{ AllowedTypes: ".avif,.cpuprofile,.csv,.dmp,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.json,.jsonc,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.webp,.xls,.xlsx,.zip", - MaxSize: 2048, + MaxSize: 100, MaxFiles: 5, Enabled: true, } From ea14df540ef278230a939ecada0e18379f3d24b9 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 22 Feb 2026 11:06:24 +0800 Subject: [PATCH 9/9] Update modules/setting/repository.go Signed-off-by: wxiaoguang --- modules/setting/repository.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setting/repository.go b/modules/setting/repository.go index fca696f010288..662e03598b5e4 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -248,7 +248,7 @@ var ( }{ AllowedTypes: "", DefaultPagingNum: 10, - FileMaxSize: 2048, // Same defaults as attachment + FileMaxSize: 2048, MaxFiles: 5, },