From 341577c35c22fe8ed21d89dfc666cf8c5e6bd4d9 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Thu, 3 Oct 2019 01:17:43 -0400 Subject: [PATCH] try a limiter here --- activity.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/activity.go b/activity.go index 160febf..3eac69a 100644 --- a/activity.go +++ b/activity.go @@ -149,9 +149,13 @@ func savedonk(url string, name, desc, media string, localize bool) *Donk { goto saveit } var buf bytes.Buffer - io.Copy(&buf, resp.Body) + limiter := io.LimitReader(resp.Body, 10 * 1024 * 1024) + io.Copy(&buf, limiter) data = buf.Bytes() + if len(data) == 10 * 1024 * 1024 { + log.Printf("truncation likely") + } if strings.HasPrefix(media, "image") { img, err := image.Vacuum(&buf, image.Params{LimitSize: 4800 * 4800, MaxWidth: 2048, MaxHeight: 2048})