From 30d39584f0667176fe487bcffd6a849b751f5fe9 Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Mon, 10 Feb 2025 20:03:00 +0800 Subject: [PATCH] fix --- test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test.py b/test.py index 1baa68d..def2911 100644 --- a/test.py +++ b/test.py @@ -2,7 +2,7 @@ from src.common.naming import FileNaming from src.common.ComicInfo import ImageInfo from zipfile import ZipFile from datetime import datetime -import time +import time, shutil import os,hashlib import xml.etree.ElementTree as ET from PIL import Image @@ -210,7 +210,7 @@ class comicInfo: # 创建临时文件处理覆盖操作 with NamedTemporaryFile(delete=False) as tmp: tmp.close() - os.replace(cbz_path, tmp.name) # 备份原文件 + shutil.copy(cbz_path, tmp.name) # 读取原文件并替换 ComicInfo.xml with ZipFile(tmp.name, 'r') as source_zip: @@ -223,7 +223,7 @@ class comicInfo: # 添加新 XML new_zip.writestr("ComicInfo.xml", new_xml_content) - os.remove(tmp.name) # 清理临时文件 + shutil.rmtree(tmp.name) # 清理临时文件 return True except Exception as e: print(f"更新 CBZ 文件失败: {e}") @@ -277,7 +277,7 @@ if __name__ == "__main__": create_time = time.localtime(os.path.getctime(file)) # 注意:st_birthtime 在Linux/MacOS中可用,但不是所有系统都支持 # 格式化时间 formatted_time = time.strftime('%Y%m%d', create_time) - if int(formatted_time) < 20250204: + if int(formatted_time) > 20250204: print(f"{file} 文件创建时间:", formatted_time) comicInfo().update_comicinfo_cbz(file) #if size < 3000: