diff --git a/src/common/naming.py b/src/common/naming.py index 4436031..86d068c 100644 --- a/src/common/naming.py +++ b/src/common/naming.py @@ -94,6 +94,7 @@ class FileNaming: if is_update and remove: try: os.remove(path) + is_update = False except: raise exit(f"file_update_by_date() {path} 删除失败") return is_update diff --git a/src/common/utils.py b/src/common/utils.py index 4be3ebd..758b22c 100644 --- a/src/common/utils.py +++ b/src/common/utils.py @@ -198,10 +198,10 @@ 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: """下载单个图片,增加重试机制、超时等待和文件缓存机制""" - FileNaming().file_update_by_date(save_path, remove=True) if os.path.exists(FileNaming.getFileScrambleImageSave(save_path)): # 检查文件是否已存在 - logger.info(f"文件已存在,跳过下载: {save_path}") - return True + if FileNaming().file_update_by_date(save_path, remove=True): + logger.info(f"文件已存在,跳过下载: {save_path}") + return True # 从缓存中获取图片 cached_images = self.cache.get_image(url) if cached_images: