fix(export): ignore file size for export files
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2023-01-11 18:56:30 +01:00
parent 04614614fe
commit 82f4a5ad50
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 4 additions and 4 deletions

View File

@ -83,7 +83,7 @@ func CreateWithMime(f io.Reader, realname string, realsize uint64, a web.Auth, m
s := db.NewSession()
defer s.Close()
file, err = CreateWithMimeAndSession(s, f, realname, realsize, a, mime)
file, err = CreateWithMimeAndSession(s, f, realname, realsize, a, mime, true)
if err != nil {
_ = s.Rollback()
return
@ -91,14 +91,14 @@ func CreateWithMime(f io.Reader, realname string, realsize uint64, a web.Auth, m
return
}
func CreateWithMimeAndSession(s *xorm.Session, f io.Reader, realname string, realsize uint64, a web.Auth, mime string) (file *File, err error) {
func CreateWithMimeAndSession(s *xorm.Session, f io.Reader, realname string, realsize uint64, a web.Auth, mime string, checkFileSizeLimit bool) (file *File, err error) {
// Get and parse the configured file size
var maxSize datasize.ByteSize
err = maxSize.UnmarshalText([]byte(config.FilesMaxSize.GetString()))
if err != nil {
return nil, err
}
if realsize > maxSize.Bytes() {
if realsize > maxSize.Bytes() && checkFileSizeLimit {
return nil, ErrFileIsTooLarge{Size: realsize}
}

View File

@ -97,7 +97,7 @@ func ExportUserData(s *xorm.Session, u *user.User) (err error) {
return err
}
exportFile, err := files.CreateWithMimeAndSession(s, exported, tmpFilename, uint64(stat.Size()), u, "application/zip")
exportFile, err := files.CreateWithMimeAndSession(s, exported, tmpFilename, uint64(stat.Size()), u, "application/zip", false)
if err != nil {
return err
}