Преглед на файлове

Check source content length before getting download buffer

DarthSim преди 6 години
родител
ревизия
c6145a8e69
променени са 1 файла, в които са добавени 4 реда и са изтрити 0 реда
  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)