From 7aaa4abeeef7b424a67a3bdca1a67e96d9bd2dd8 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Thu, 24 Jun 2021 11:25:29 -0300 Subject: util: Do not store "" as the message CH This was causing assertions if this condition was ever hit. Instead just delete the corrupted message id. Signed-off-by: Jason Gunthorpe --- cloud_mdir_sync/messages.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cloud_mdir_sync/messages.py b/cloud_mdir_sync/messages.py index 73cbf80..fd8922d 100644 --- a/cloud_mdir_sync/messages.py +++ b/cloud_mdir_sync/messages.py @@ -211,8 +211,9 @@ class MessageDB(object): for cid,ch in res.items(): ncid = (cid[0], cid[1], None) if no_msg_id.get(ncid, ch) != ch: - ch = "" - no_msg_id[ncid] = ch + del no_msg_id[ncid] + else: + no_msg_id[ncid] = ch self.content_hashes_cloud = no_msg_id def _sha1_fn(self, fn): @@ -297,7 +298,7 @@ class MessageDB(object): """Return a file for later use by store_hashed_file""" return tempfile.NamedTemporaryFile(dir=self.hashes_dir) - def store_hashed_msg(self, msg, tmpf): + def store_hashed_msg(self, msg : Message, tmpf): """Retain the content tmpf in the hashed file database""" tmpf.flush() ch = self._sha1_fn(tmpf.name) @@ -317,8 +318,6 @@ class MessageDB(object): cid = msg.cid() self.content_hashes[msg.cid()] = ch ncid = (cid[0], cid[1], None) - if self.content_hashes_cloud.get(ncid, ch) != ch: - ch = "" self.content_hashes_cloud[ncid] = ch assert self.have_content(msg) -- cgit v1.2.3