diff --git a/sapl/base/search_indexes.py b/sapl/base/search_indexes.py index 58e1688c4..61fe3438a 100644 --- a/sapl/base/search_indexes.py +++ b/sapl/base/search_indexes.py @@ -32,10 +32,7 @@ class DocumentoAcessorioIndex(indexes.SearchIndex, indexes.Indexable): arquivo = getattr(obj, self.filename) if arquivo: - try: - arquivo.open() - arquivo.close() - except OSError: + if not os.path.exists(arquivo.path): return self.prepared_data if not os.path.splitext(arquivo.path)[1][:1]: @@ -43,10 +40,13 @@ class DocumentoAcessorioIndex(indexes.SearchIndex, indexes.Indexable): try: extracted_data = textract.process( - arquivo.path).decode( - 'utf-8').replace('\n', ' ') + arquivo.path, + language='pt-br').decode('utf-8').replace('\n', ' ') except ExtensionNotSupported: return self.prepared_data + except Exception: + print('Erro inesperado processando arquivo: %s' % arquivo.path) + return self.prepared_data extracted_data = extracted_data.replace('\t', ' ')