only detect when not sure about the types

This commit is contained in:
Chris Lu 2020-04-14 11:02:05 -07:00
parent d2d1597850
commit 3f1d79512f

View file

@ -79,7 +79,7 @@ func doUploadData(uploadUrl string, filename string, cipher bool, data []byte, i
if !isInputGzipped { if !isInputGzipped {
if shouldBeZipped, iAmSure := util.IsGzippableFileType(filepath.Base(filename), mtype); iAmSure && shouldBeZipped { if shouldBeZipped, iAmSure := util.IsGzippableFileType(filepath.Base(filename), mtype); iAmSure && shouldBeZipped {
shouldGzipNow = true shouldGzipNow = true
} else if mtype == "" && len(data) > 128 { } else if !iAmSure && mtype == "" && len(data) > 128 {
var compressed []byte var compressed []byte
compressed, err = util.GzipData(data[0:128]) compressed, err = util.GzipData(data[0:128])
shouldGzipNow = len(compressed)*10 < 128*9 // can not compress to less than 90% shouldGzipNow = len(compressed)*10 < 128*9 // can not compress to less than 90%