From 193d2d904ba3aca4265c552a4e1512c976e5a9e2 Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Mon, 16 Jan 2023 02:31:42 +0800 Subject: [PATCH] fix --- utils/CBZUtils.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/utils/CBZUtils.py b/utils/CBZUtils.py index 5887e6a..7886eee 100644 --- a/utils/CBZUtils.py +++ b/utils/CBZUtils.py @@ -1,5 +1,6 @@ import json import os,shutil +from datetime import datetime from pathlib import Path from zipfile import ZipFile from utils.comic.ComicInfo import comicInfo @@ -98,19 +99,15 @@ class CBZUtils: for file in fz.namelist(): fz.extract(file, unpack_dir) zip_imgs = os.listdir(unpack_dir) - is_file = [] for img in zip_imgs: if img.endswith(".jpg"): - file_path = os.path.join(unpack_dir,img) - is_file.append(str(fileUtils.ver_file(file_path,"image"))) - is_file = ",".join(is_file) - if len(is_file) != 0 and "False" in is_file: + img_path = os.path.join(unpack_dir,img) + is_file = fileUtils.ver_file(img_path,"image") + if not is_file and os.path.exists(filepath): + os.remove(filepath) + print(f"数据不完整,已删除:{filepath}") + if os.path.exists(unpack_dir): shutil.rmtree(unpack_dir) - os.remove(file_path) - print(f"已删除{file_path}") - else: - shutil.rmtree(unpack_dir) - print(f"数据完整:{file_path}") # 删除删除main.ftl文件 #delete_filename = '' #if os.path.exists(delete_filename):