Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Download in 1KB chunks to reduce memory footprint
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixelguin committed Sep 16, 2023
1 parent 3b73df4 commit bfef7d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Persona.PrerequisiteInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,12 @@ def download_file(path, url):

# If request was successful, open file for writing and write content from the URL
if response.ok:
# Download file in 1KB chunks
with open(path,'wb') as download:
download.write(response.content)
for chunk in response.iter_content(chunk_size = 1024):
if chunk:
download.write(chunk)
log.debug(f'Finished downloading {path}!')

# If redirect history is not empty, log redirect
if response.history:
Expand Down

0 comments on commit bfef7d7

Please sign in to comment.