Jelajahi Sumber

Check source content length before getting download buffer

DarthSim 6 tahun lalu
induk
melakukan
c6145a8e69
1 mengubah file dengan 4 tambahan dan 0 penghapusan
  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)