From 32555824bb3103bcef1ce626ce7a0a46bd616e17 Mon Sep 17 00:00:00 2001 From: butaixianran Date: Thu, 28 Sep 2023 10:24:53 +0800 Subject: [PATCH] fix downloading size check issue --- scripts/ch_lib/downloader.py | 6 ++++++ scripts/ch_lib/util.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/ch_lib/downloader.py b/scripts/ch_lib/downloader.py index 58fdb9c..9e70942 100644 --- a/scripts/ch_lib/downloader.py +++ b/scripts/ch_lib/downloader.py @@ -109,6 +109,12 @@ def dl(url, folder, filename, filepath): print() + # check file size + downloaded_size = os.path.getsize(dl_file_path) + if downloaded_size < total_size: + util.printD(f"Download failed due to insufficient file size. Try again later or download it manually: {url}") + return + # rename file os.rename(dl_file_path, file_path) util.printD(f"File Downloaded to: {file_path}") diff --git a/scripts/ch_lib/util.py b/scripts/ch_lib/util.py index 9eaa3dd..a2e6294 100644 --- a/scripts/ch_lib/util.py +++ b/scripts/ch_lib/util.py @@ -6,7 +6,7 @@ import requests import shutil -version = "1.8.1" +version = "1.8.2" def_headers = {'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'}