Ver código fonte

修复 附件下载失败后返回结果不一致导致的 IndexError

dongzhaorui 1 ano atrás
pai
commit
b8565064cb
1 arquivos alterados com 2 adições e 8 exclusões
  1. 2 8
      FworkSpider/untils/attachment_res.py

+ 2 - 8
FworkSpider/untils/attachment_res.py

@@ -224,7 +224,7 @@ class AttachmentDownloader(AliYunService):
                 if show_error_log:
                     logger.exception(why)
 
-        return b''
+        return b"", ""
 
     def fetch_attachment(
         self,
@@ -236,13 +236,7 @@ class AttachmentDownloader(AliYunService):
         if not file_name or not download_url:
             raise AttachmentNullError
 
-        results = self.fetch_data(callback, download_url, **kwargs)
-        if len(results) == 2:
-            filetype = results[-1]
-        else:
-            filetype = ""
-
-        filestream = results[0]  # 文件数据流
+        filestream, filetype = self.fetch_data(callback, download_url, **kwargs)
         filename = clear_file_type_suffix(file_name, filetype)
         download_url = judge_file_url(download_url)