mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 06:33:51 +00:00 
			
		
		
		
	Fixes compressed downloads (#5014)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
		| @@ -546,22 +546,11 @@ class DownloadBinaryRequestHandler(BaseHandler): | |||||||
|             return |             return | ||||||
|  |  | ||||||
|         with open(path, "rb") as f: |         with open(path, "rb") as f: | ||||||
|             while True: |             data = f.read() | ||||||
|                 # For a 528KB image used as benchmark: |  | ||||||
|                 #   - using 256KB blocks resulted in the smallest file size. |  | ||||||
|                 #   - blocks larger than 256KB didn't improve the size of compressed file. |  | ||||||
|                 #   - blocks smaller than 256KB hindered compression, making the output file larger. |  | ||||||
|  |  | ||||||
|                 # Read file in blocks of 256KB. |  | ||||||
|                 data = f.read(256 * 1024) |  | ||||||
|  |  | ||||||
|                 if not data: |  | ||||||
|                     break |  | ||||||
|  |  | ||||||
|             if compressed: |             if compressed: | ||||||
|                 data = gzip.compress(data, 9) |                 data = gzip.compress(data, 9) | ||||||
|  |  | ||||||
|             self.write(data) |             self.write(data) | ||||||
|  |  | ||||||
|         self.finish() |         self.finish() | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user