fix: 分段不支持类型的文件报错

This commit is contained in:
shaohuzhang1 2024-04-10 17:05:46 +08:00
parent c0d0f53baa
commit 8b31fd6b36

View File

@ -29,7 +29,8 @@ class TextSplitHandle(BaseSplitHandle):
if file_name.endswith(".md") or file_name.endswith('.txt'):
return True
result = detect(buffer)
if result['encoding'] != 'ascii' and result['confidence'] > 0.5:
if result['encoding'] is not None and result['confidence'] is not None and result['encoding'] != 'ascii' and \
result['confidence'] > 0.5:
return True
return False