Ver Fonte

Check source content length before getting download buffer

DarthSim há 6 anos atrás
pai
commit
c6145a8e69
1 ficheiros alterados com 4 adições e 0 exclusões
  1. 4 0
      download.go

+ 4 - 0
download.go

@@ -125,6 +125,10 @@ func readAndCheckImage(ctx context.Context, res *http.Response) (context.Context
 
 	if res.ContentLength > 0 {
 		contentLength = int(res.ContentLength)
+
+		if conf.MaxSrcFileSize > 0 && contentLength > conf.MaxSrcFileSize {
+			return ctx, func() {}, errSourceFileTooBig
+		}
 	}
 
 	buf := downloadBufPool.Get(contentLength)