From fa64225c5818d854ba0aa0862ccdcbf1c99b22b4 Mon Sep 17 00:00:00 2001 From: raphael60650 Date: Fri, 21 May 2021 22:35:43 +0200 Subject: [PATCH] Updater now download by chunk --- Updater/Updater.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Updater/Updater.py b/Updater/Updater.py index 5613c97..adf478c 100644 --- a/Updater/Updater.py +++ b/Updater/Updater.py @@ -14,10 +14,10 @@ try: gitversion = requests.get(VERSION_FILE_URL, allow_redirects=True).json() URL = gitversion["download_bin"] - dl = requests.get(URL, allow_redirects=True) + dl = requests.get(URL, allow_redirects=True, stream=True) with open("./download.zip", "wb") as file: print(f"Téléchargement de la version {gitversion['version']}.{gitversion['subversion']} en cours...") - file.write(dl.content) + for chunk in dl.iter_content(chunk_size=1024): file.write(chunk) print("fin du téléchargement, début de l'extraction...") with zipfile.ZipFile("./download.zip") as file: @@ -30,6 +30,4 @@ try: except Exception as e: print(f"Impossible d'effectuer la mise à jour :\n\n{str(e)}") - input("Appuyez pour continuer...") - -# TODO: Utiliser un buffer pour éviter de consommer trop de RAM pendant le téléchargement \ No newline at end of file + input("Appuyez pour continuer...") \ No newline at end of file