Explorar o código

Check source content length before getting download buffer

DarthSim %!s(int64=6) %!d(string=hai) anos
pai
achega
c6145a8e69
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  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)