From fc78bcada6062cada7e7c5b417bf1fae8984eac0 Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Fri, 20 Jan 2023 03:53:57 +0800 Subject: [PATCH] fix --- utils/downloader.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/utils/downloader.py b/utils/downloader.py index b5999a7..6d026ce 100644 --- a/utils/downloader.py +++ b/utils/downloader.py @@ -37,7 +37,7 @@ def download_image(image_url, dst_dir, file_name, timeout=20, proxy_type=None, p response = None file_path = os.path.join(dst_dir, file_name) if os.path.exists(file_path): - print("文件已存在,已跳过=",file_path) + print("download_image 文件已存在,已跳过=",file_path) return None temp_path = os.path.join(dst_dir, file_name+".downloads") repair_count = 1 @@ -87,8 +87,12 @@ def download_images(image_urls, dst_dir, file_prefix="img", concurrency=50, time if not os.path.exists(dst_dir): os.makedirs(dst_dir) for image_url in image_urls: - file_name = filesName[count] - future_list.append(executor.submit( + file_name = filesName[count] + file_path = os.path.join(dst_dir, file_name) + if os.path.exists(file_path): + print("文件已存在,已跳过=",file_path) + else: + future_list.append(executor.submit( download_image, image_url, dst_dir, file_name, timeout, proxy_type, proxy)) count += 1 concurrent.futures.wait(future_list, timeout)