From 9a04a96eb7f2c2afc544fe6a92132f2968afe3bd Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Fri, 21 Feb 2020 11:23:38 -0400 Subject: Fix an exception if message fetching fails Since size is used to print the log message, even on failure, set it to some value. Signed-off-by: Jason Gunthorpe --- cloud_mdir_sync/gmail.py | 1 + cloud_mdir_sync/office365.py | 1 + 2 files changed, 2 insertions(+) diff --git a/cloud_mdir_sync/gmail.py b/cloud_mdir_sync/gmail.py index 949798b..b1d2b55 100644 --- a/cloud_mdir_sync/gmail.py +++ b/cloud_mdir_sync/gmail.py @@ -388,6 +388,7 @@ class GMailMailbox(mailbox.Mailbox): async def _fetch_message(self, msg: GMailMessage): msgdb = self.msgdb + msg.size = 0 with util.log_progress_ctx(logging.DEBUG, f"Downloading {msg.storage_id}", lambda msg: f" {util.sizeof_fmt(msg.size)}", diff --git a/cloud_mdir_sync/office365.py b/cloud_mdir_sync/office365.py index 9cfaf0d..5c52228 100644 --- a/cloud_mdir_sync/office365.py +++ b/cloud_mdir_sync/office365.py @@ -404,6 +404,7 @@ class O365Mailbox(mailbox.Mailbox): @mailbox.update_on_failure async def _fetch_message(self, msg: messages.Message): msgdb = self.msgdb + msg.size = 0 with util.log_progress_ctx(logging.DEBUG, f"Downloading {msg.email_id}", lambda msg: f" {util.sizeof_fmt(msg.size)}", -- cgit v1.2.3