Use random filename for textual indexation #31911

This commit is contained in:
Nicolas Demonte 2019-04-02 17:08:09 +02:00
parent abed4c8dd4
commit 380797db49
1 changed files with 6 additions and 2 deletions

View File

@ -10,7 +10,7 @@ from pfwbged.folder import IFolder
from collective.dms.basecontent.dmsdocument import IDmsDocument
from plone import api
from uuid import uuid1
from .behaviors import IPfwbDocument
@ -37,9 +37,13 @@ def document_dynamic_searchable_text_indexer(obj):
# convert it to text/plain
try:
temp_filename = '{0}.{1}'.format(
uuid1(),
child.file.filename.split('.')[-1],
)
datastream = transforms.convertTo(
'text/plain', child.file.data, mimetype=child.file.contentType,
filename=child.file.filename.encode('utf-8'))
filename=temp_filename)
indexed_elements.append(unicode(datastream.getData(), 'utf-8',
'ignore'))
except (ConflictError, KeyboardInterrupt):