diff --git a/utils/CBZUtils.py b/utils/CBZUtils.py index 16e872d..538fdce 100644 --- a/utils/CBZUtils.py +++ b/utils/CBZUtils.py @@ -93,15 +93,7 @@ class CBZUtils: @classmethod def replaceZip(cls,filepath,unpack_dir=None): - if os.path.exists(filepath): - ctime = os.path.getmtime(filepath) - str_ctime = datetime.fromtimestamp(int(ctime)) - file_ctime = str(str_ctime.year)+"{:0>2d}".format(str_ctime.month)+"{:0>2d}".format(str_ctime.day)+"{:0>2d}".format(str_ctime.hour) - c_ctime = 2023011603 - if int(file_ctime) > c_ctime: - return None - else: - return None + if not cls.compareFileDate(filepath): return None if unpack_dir == None: unpack_dir = str(filepath).split(".")[0] fz = ZipFile(filepath, 'r') @@ -115,7 +107,7 @@ class CBZUtils: if not is_file and os.path.exists(filepath): os.remove(filepath) print(f"数据不完整,已删除:{filepath}") - if is_file and os.path.exists(filepath): + if is_file and cls.compareFileDate(filepath): os.utime(filepath) print(f"已更新文件时间 {filepath}") if os.path.exists(unpack_dir): @@ -127,6 +119,17 @@ class CBZUtils: # time.sleep(60) # shutil.copy(文件的路径,另一个目录);拷贝main.ftl到准备压缩的目录下 #cls.zip_compression() + #小于则运行 + @classmethod + def compareFileDate(cls,filepath): + if os.path.exists(filepath): + ctime = os.path.getmtime(filepath) + str_ctime = datetime.fromtimestamp(int(ctime)) + file_ctime = str(str_ctime.year)+"{:0>2d}".format(str_ctime.month)+"{:0>2d}".format(str_ctime.day)+"{:0>2d}".format(str_ctime.hour) + c_ctime = 2023011603 + if int(file_ctime) > c_ctime: + return False + return True class verUtils: @classmethod