From 0e7f1f2945485f75d1f28159a3d2b29d0d214607 Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Tue, 14 Feb 2023 04:22:01 +0800 Subject: [PATCH] fix --- utils/CBZUtils.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/utils/CBZUtils.py b/utils/CBZUtils.py index 27edbe4..41f8d65 100644 --- a/utils/CBZUtils.py +++ b/utils/CBZUtils.py @@ -61,10 +61,15 @@ class CBZUtils: zf.close() ntfy.sendMsg(f"打包完成:{target_file}") else: - with ZipFile(target_file, "r") as zfile: - filenames = zfile.namelist() - zfile.close() print("文件已存在:", target_file) + len_chapter_imgs = len(comicInfo.getChapterImgs()) + if len_chapter_imgs != 0 and len_chapter_imgs != cls.zip_info(target_file): + try: + os.remove(target_file) + comicInfo.setProgress(comicInfo.PROGRESS_NONE) + print("文件已删除:", target_file) + except Exception as e: + print(e) if remove: filenames.remove(comicInfo.COMIC_ICON_NAME+".jpg") filenames.remove(comicInfo.COMIC_INFO_XML) @@ -125,11 +130,11 @@ class CBZUtils: return False @classmethod - def zip_info(cls,path,filter=False): + def zip_info(cls,path,filter=True): result = None try: - zip_file = ZipFile(path) - result = zip_file.namelist() + with ZipFile(path, "r") as zip_file: + result = zip_file.namelist() if filter: result.remove(comicInfo.COMIC_ICON_NAME+".jpg") result.remove(comicInfo.COMIC_INFO_XML)