aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@mellanox.com>2020-02-21 11:23:38 -0400
committerJason Gunthorpe <jgg@mellanox.com>2020-02-21 11:23:38 -0400
commit9a04a96eb7f2c2afc544fe6a92132f2968afe3bd (patch)
tree7674da4ba517590e97ce3e77c73650fecd3f88ae
parentd1877aaf5a791204dd7222f50fc33b5f802c7e94 (diff)
downloadcloud_mdir_sync-9a04a96eb7f2c2afc544fe6a92132f2968afe3bd.tar.gz
cloud_mdir_sync-9a04a96eb7f2c2afc544fe6a92132f2968afe3bd.tar.bz2
cloud_mdir_sync-9a04a96eb7f2c2afc544fe6a92132f2968afe3bd.zip
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 <jgg@mellanox.com>
-rw-r--r--cloud_mdir_sync/gmail.py1
-rw-r--r--cloud_mdir_sync/office365.py1
2 files changed, 2 insertions, 0 deletions
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)}",