diff options
| author | P. Christeas <p_christ@hol.gr> | 2010-07-01 20:51:31 +0300 |
|---|---|---|
| committer | P. Christeas <p_christ@hol.gr> | 2010-07-01 20:51:31 +0300 |
| commit | 8307ff013916ffcaf8c7f0c8a796df77a64bfcd4 (patch) | |
| tree | 98ad7f9b2273f39d003ce6b4978ef61fbc01cf21 /addons/document/document_storage.py | |
| parent | 6aef03991d174112c5787502e825ee4895f52bf0 (diff) | |
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
Diffstat (limited to 'addons/document/document_storage.py')
| -rw-r--r-- | addons/document/document_storage.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/document/document_storage.py b/addons/document/document_storage.py index b2db4eb36a6..26ba5dea772 100644 --- a/addons/document/document_storage.py +++ b/addons/document/document_storage.py @@ -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)) |
