Mercurial > libervia-backend
comparison sat/memory/sqlite.py @ 3545:31cbcdd096a2
memory (sqlite): work around encoding issues with pickle
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 04 Jun 2021 14:07:58 +0200 |
parents | 67aebefb44fc |
children | 0ce37cf3fbf4 |
comparison
equal
deleted
inserted
replaced
3544:ae5f63e5ed2c | 3545:31cbcdd096a2 |
---|---|
533 received_timestamp, type_, extra, message, message_lang, subject, | 533 received_timestamp, type_, extra, message, message_lang, subject, |
534 subject_lang, thread, thread_parent) = row | 534 subject_lang, thread, thread_parent) = row |
535 if uid != current['uid']: | 535 if uid != current['uid']: |
536 # new message | 536 # new message |
537 try: | 537 try: |
538 extra = pickle.loads(extra or b"") | 538 extra = self._load_pickle(extra or b"") |
539 except EOFError: | 539 except EOFError: |
540 extra = {} | 540 extra = {} |
541 current = { | 541 current = { |
542 'from': "%s/%s" % (source, source_res) if source_res else source, | 542 'from': "%s/%s" % (source, source_res) if source_res else source, |
543 'to': "%s/%s" % (dest, dest_res) if dest_res else dest, | 543 'to': "%s/%s" % (dest, dest_res) if dest_res else dest, |
1657 for idx, row in enumerate(rows, 1): | 1657 for idx, row in enumerate(rows, 1): |
1658 if idx % 1000 == 0 or total - idx == 0: | 1658 if idx % 1000 == 0 or total - idx == 0: |
1659 log.info("preparing message {}/{}".format(idx, total)) | 1659 log.info("preparing message {}/{}".format(idx, total)) |
1660 id_, timestamp, message, extra = row | 1660 id_, timestamp, message, extra = row |
1661 try: | 1661 try: |
1662 extra = pickle.loads(str(extra or "")) | 1662 extra = self._load_pickle(extra or b"") |
1663 except EOFError: | 1663 except EOFError: |
1664 extra = {} | 1664 extra = {} |
1665 except Exception: | 1665 except Exception: |
1666 log.warning("Can't handle extra data for message id {}, ignoring it".format(id_)) | 1666 log.warning("Can't handle extra data for message id {}, ignoring it".format(id_)) |
1667 extra = {} | 1667 extra = {} |