summaryrefslogtreecommitdiff
path: root/internal/media/util.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-09-27 11:15:53 +0000
committerLibravatar GitHub <noreply@github.com>2024-09-27 13:15:53 +0200
commit497ebd8c4e9db9a1351b841cc7fe04c960fb7987 (patch)
treea729e3e83cc60a85b70ac052b2549c9ffb4e3d7d /internal/media/util.go
parent[chore] final bits of fiddling with solarized (#3364) (diff)
downloadgotosocial-497ebd8c4e9db9a1351b841cc7fe04c960fb7987.tar.xz
[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
Diffstat (limited to 'internal/media/util.go')
-rw-r--r--internal/media/util.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/internal/media/util.go b/internal/media/util.go
index 22121a546..538d6f572 100644
--- a/internal/media/util.go
+++ b/internal/media/util.go
@@ -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