Procházet zdrojové kódy

fix encoding is none (#394)

tags/0.3.4
Jyong před 2 roky
rodič
revize
b08c19d926
Žádný účet není propojen s e-mailovou adresou tvůrce revize
1 změnil soubory, kde provedl 4 přidání a 1 odebrání
  1. 4
    1
      api/controllers/console/datasets/file.py

+ 4
- 1
api/controllers/console/datasets/file.py Zobrazit soubor

@@ -143,7 +143,10 @@ class FilePreviewApi(Resource):
with open(filepath, "rb") as fp:
data = fp.read()
encoding = chardet.detect(data)['encoding']
text = data.decode(encoding=encoding).strip() if data else ''
if encoding:
text = data.decode(encoding=encoding).strip() if data else ''
else:
text = data.decode(encoding='utf-8').strip() if data else ''

text = text[0:PREVIEW_WORDS_LIMIT] if text else ''
return {'content': text}

Načítá se…
Zrušit
Uložit