From 3d90734534244b6bc5d8c23030c8fc628c0a639f Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Fri, 29 Aug 2025 11:30:28 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E4=BC=98=E5=8C=96=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=86=85=E5=AE=B9=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=AF=B9=E9=9D=9E=E4=BA=8C=E8=BF=9B?= =?UTF-8?q?=E5=88=B6=E6=96=87=E4=BB=B6=E7=9A=84UTF-8=E8=A7=A3=E7=A0=81?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=8C=E6=8F=90=E5=8D=87=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E7=9A=84=E7=A8=B3=E5=AE=9A=E6=80=A7=E5=92=8C?= =?UTF-8?q?=E5=87=86=E7=A1=AE=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/utils/repo_utils/file_manager.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/zhenxun/utils/repo_utils/file_manager.py b/zhenxun/utils/repo_utils/file_manager.py index d45ef008..94d50db3 100644 --- a/zhenxun/utils/repo_utils/file_manager.py +++ b/zhenxun/utils/repo_utils/file_manager.py @@ -82,18 +82,20 @@ class RepoFileManager: ) if response.status_code == 200: logger.info(f"获取github文件内容成功: {f}", LOG_COMMAND) + text_content = response.content # 确保使用UTF-8编码解析响应内容 - try: - text_content = response.content.decode("utf-8") - except UnicodeDecodeError: - # 如果UTF-8解码失败,尝试其他编码 - text_content = response.content.decode( - "utf-8", errors="ignore" - ) - logger.warning( - f"解码文件内容时出现错误,使用忽略错误模式: {f}", - LOG_COMMAND, - ) + if not is_binary_file(f): + try: + text_content = response.content.decode("utf-8") + except UnicodeDecodeError: + # 如果UTF-8解码失败,尝试其他编码 + text_content = response.content.decode( + "utf-8", errors="ignore" + ) + logger.warning( + f"解码文件内容时出现错误,使用忽略错误模式:{f}", + LOG_COMMAND, + ) results.append((f, text_content)) break else: