Skip to content

Commit 129a866

Browse files
committed
完善异常上抛机制
1 parent 879cf04 commit 129a866

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/jmcomic/jm_downloader.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def all_success(self) -> bool:
209209
210210
注意!如果使用了filter机制,例如通过filter只下载3张图片,那么all_success也会为False
211211
"""
212-
if len(self.download_failed_image) != 0:
212+
if not self.is_empty_download_failed:
213213
return False
214214

215215
for album, photo_dict in self.download_success_dict.items():
@@ -222,6 +222,10 @@ def all_success(self) -> bool:
222222

223223
return True
224224

225+
@property
226+
def is_empty_download_failed(self):
227+
return len(self.download_failed_image) == 0 and len(self.download_failed_photo) == 0
228+
225229
# 下面是回调方法
226230

227231
def before_album(self, album: JmAlbumDetail):
@@ -280,7 +284,7 @@ def after_image(self, image: JmImageDetail, img_save_path):
280284
)
281285

282286
def raise_if_have_exception(self):
283-
if len(self.download_failed_image) == 0 and len(self.download_success_dict) == 0:
287+
if self.is_empty_download_failed:
284288
return
285289
ExceptionTool.raises(
286290
f'部分下载失败: 有{len(self.download_failed_photo)}个章节下载失败, {len(self.download_failed_image)}个图片下载失败',

0 commit comments

Comments
 (0)