From 34882e87c71ed8d42e546cce1a63fde8379cbe33 Mon Sep 17 00:00:00 2001 From: Evil0ctal Date: Mon, 11 Apr 2022 23:36:41 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E9=94=AE=E4=B8=8B=E8=BD=BD=E8=A7=86=E9=A2=91bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Web/web_zh.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Web/web_zh.py b/Web/web_zh.py index 025bf36..5518866 100644 --- a/Web/web_zh.py +++ b/Web/web_zh.py @@ -105,12 +105,14 @@ def compress_file(tar_file, target_file): if os.path.isfile(target_file): with tarfile.open(tar_file, 'w') as tar: tar.add(target_file) + return 'finished' else: with tarfile.open(tar_file, 'w') as tar: for root, dirs, files in os.walk(target_file): for single_file in files: filepath = os.path.join(root, single_file) tar.add(filepath) + return 'finished' def clean_file(path): @@ -165,12 +167,13 @@ def video_download_window(result_dict): output_path = save_path + '/output' tarfile_name = download_time + '_total_' + str(total_amount) + '_videos.tar' output_file = output_path + '/' + tarfile_name + put_info('正在压缩视频文件,请勿关闭当前弹窗,完成后会在下方显示按钮...') # 判断目录是否存在 if not os.path.exists(output_path): os.mkdir(output_path) - compress_file(tar_file=output_file, target_file=save_path) - tar = open(output_file, "rb").read() - put_file(tarfile_name, tar, '点击下载视频合集压缩包') + if compress_file(tar_file=output_file, target_file=save_path) == 'finished': + tar = open(output_file, "rb").read() + put_file(tarfile_name, tar, '点击下载视频合集压缩包') except Exception as e: print(str(e))