From 96c22b7298234bb46e918a5e6d667263b64bae97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=9A=E9=A3=8E=E6=8B=82=E6=9F=B3=E9=A2=9C?= <434857005@qq.com> Date: Fri, 7 Jul 2023 15:46:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8D=87=E7=BA=A7=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/version.txt | 2 +- utils/update.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/js/version.txt b/js/version.txt index 67e32cf..66642d9 100644 --- a/js/version.txt +++ b/js/version.txt @@ -1 +1 @@ -3.9.46beta8 \ No newline at end of file +3.9.46beta9 \ No newline at end of file diff --git a/utils/update.py b/utils/update.py index e780f5c..9abd51f 100644 --- a/utils/update.py +++ b/utils/update.py @@ -106,6 +106,11 @@ def del_file(filepath): file_path = os.path.join(filepath, f) if os.path.isfile(file_path): os.remove(file_path) + else: + try: + shutil.rmtree(file_path) + except Exception as e: + logger.info(f'删除{file_path}发生错误:{e}') def copytree(src, dst, ignore=None): if ignore is None: @@ -194,7 +199,6 @@ def download_new_version(update_proxy='https://ghproxy.liuzhicong.com/'): # for tp in tmp_files: # print(f'清除缓存文件:{tp}') # os.remove(os.path.join(tmp_path, tp)) - del_file(tmp_path) msg = '' try: # print(f'开始下载:{url}') @@ -202,6 +206,8 @@ def download_new_version(update_proxy='https://ghproxy.liuzhicong.com/'): r = requests.get(url,headers=headers,timeout=(20,20),verify=False) rb = r.content download_path = os.path.join(tmp_path, 'dr_py.zip') + # 保存文件前清空目录 + del_file(tmp_path) with open(download_path,mode='wb+') as f: f.write(rb) # print(f'开始解压文件:{download_path}')