From 94302935b2d2929f077c96b51de4287f8b63d816 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 6 Apr 2019 00:10:52 -0700 Subject: [PATCH] weed volume: only store compressed data if compression is effective --- weed/storage/needle_parse_multipart.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/weed/storage/needle_parse_multipart.go b/weed/storage/needle_parse_multipart.go index e8d57ee38..3dba81fcf 100644 --- a/weed/storage/needle_parse_multipart.go +++ b/weed/storage/needle_parse_multipart.go @@ -88,10 +88,12 @@ func parseMultipart(r *http.Request) ( } isGzipped = true } else if operation.IsGzippable(ext, mtype, data) { - if data, e = operation.GzipData(data); e != nil { - return + if compressedData, err := operation.GzipData(data); err == nil { + if len(data) > len(compressedData) { + data = compressedData + isGzipped = true + } } - isGzipped = true } }