Document: workaround case when text file consists of non-unicode.

The content indexer would be trying to process the garbage of the
file and fail.

bzr revid: p_christ@hol.gr-20100701175131-b83jg498xjuosmd9
This commit is contained in:
P. Christeas
2010-07-01 20:51:31 +03:00
parent 6aef03991d
commit 8307ff0139
+7 -2
View File
@@ -378,16 +378,21 @@ class document_storage(osv.osv):
self._doclog.debug('Cannot index file:', exc_info=True)
pass
try:
icont_u = ustr(icont)
except UnicodeError:
icont_u = ''
# a hack: /assume/ that the calling write operation will not try
# to write the fname and size, and update them in the db concurrently.
# We cannot use a write() here, because we are already in one.
cr.execute('UPDATE ir_attachment SET store_fname = %s, file_size = %s, index_content = %s, file_type = %s WHERE id = %s',
(store_fname, filesize, ustr(icont), mime, file_node.file_id))
(store_fname, filesize, icont_u, mime, file_node.file_id))
file_node.content_length = filesize
file_node.content_type = mime
return True
except Exception, e :
self._doclog.warning( "Couldn't save data:", exc_info=True)
self._doclog.warning("Couldn't save data:", exc_info=True)
# should we really rollback once we have written the actual data?
# at the db case (only), that rollback would be safe
raise except_orm(_('Error at doc write!'), str(e))