mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-10 03:08:07 -06:00
[bugfix] fix media limit reader check (#3363)
* return nicer errors for frontend when media / emoji upload limit reached * fix reader limit check * add code comment
This commit is contained in:
parent
c1c8849322
commit
497ebd8c4e
3 changed files with 37 additions and 7 deletions
|
|
@ -29,6 +29,7 @@ import (
|
|||
"codeberg.org/gruf/go-bytesize"
|
||||
"codeberg.org/gruf/go-iotools"
|
||||
"codeberg.org/gruf/go-mimetypes"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
)
|
||||
|
||||
// file represents one file
|
||||
|
|
@ -143,8 +144,9 @@ func drainToTmp(rc io.ReadCloser) (string, error) {
|
|||
|
||||
// Check to see if limit was reached,
|
||||
// (produces more useful error messages).
|
||||
if lr != nil && !iotools.AtEOF(lr.R) {
|
||||
return path, fmt.Errorf("reached read limit %s", bytesize.Size(limit))
|
||||
if lr != nil && lr.N <= 0 {
|
||||
err := fmt.Errorf("reached read limit %s", bytesize.Size(limit))
|
||||
return path, gtserror.SetLimitReached(err)
|
||||
}
|
||||
|
||||
return path, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue