From 86e0c639221b7e2723da14552d697f742f116b30 Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Tue, 4 Feb 2025 18:04:13 +0800 Subject: [PATCH] fix --- src/common/utils.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/common/utils.py b/src/common/utils.py index 758b22c..2a180d2 100644 --- a/src/common/utils.py +++ b/src/common/utils.py @@ -115,7 +115,13 @@ class MangaDownloader: save_path = DirectoryNaming.manga_cover_dir(manga_info) DirectoryNaming.ensure_dir(save_path.parent) if os.path.exists(save_path): - print("f".format(save_path)) + if FileNaming().file_update_by_date(save_path, day=7): + """需要更新刚删除原文件""" + os.remove(save_path) + else: + """不更新刚返回""" + logger.info(f"{save_path} 已是更新") + return async with aiohttp.ClientSession(headers=DEFAULT_HEADERS, timeout=aiohttp.ClientTimeout(total=TIMEOUT, connect=TIMEOUT)) as session: await self.download_image(session,str(cover_item.url), save_path) @@ -198,10 +204,11 @@ class MangaDownloader: async def download_image(self, session: aiohttp.ClientSession, url: str, save_path: Path, retries: int = RETRIES, timeout: int = TIMEOUT, use_proxy: bool = RETRY_PROXY) -> bool: """下载单个图片,增加重试机制、超时等待和文件缓存机制""" - if os.path.exists(FileNaming.getFileScrambleImageSave(save_path)): # 检查文件是否已存在 - if FileNaming().file_update_by_date(save_path, remove=True): - logger.info(f"文件已存在,跳过下载: {save_path}") - return True + #file_path = FileNaming.getFileScrambleImageSave(save_path) + #if os.path.exists(file_path): # 检查文件是否已存在 + # if not FileNaming().file_update_by_date(file_path, remove=True): + # logger.info(f"文件已存在,跳过下载: {file_path}") + # return True # 从缓存中获取图片 cached_images = self.cache.get_image(url) if cached_images: