aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cloud_mdir_sync/maildir.py1
-rw-r--r--cloud_mdir_sync/messages.py7
2 files changed, 8 insertions, 0 deletions
diff --git a/cloud_mdir_sync/maildir.py b/cloud_mdir_sync/maildir.py
index c7f1be5..51497be 100644
--- a/cloud_mdir_sync/maildir.py
+++ b/cloud_mdir_sync/maildir.py
@@ -149,6 +149,7 @@ class MailDirMailbox(mailbox.Mailbox):
# delivered it.
if cloudmsg.received_time is not None:
os.utime(fn, (time.time(), cloudmsg.received_time.timestamp()))
+ self.msgdb.update_inode_cache(msg)
self.messages[msg.content_hash] = msg
def _set_flags(self, mymsg: messages.Message, cloudmsg: messages.Message):
diff --git a/cloud_mdir_sync/messages.py b/cloud_mdir_sync/messages.py
index d7044ae..73cbf80 100644
--- a/cloud_mdir_sync/messages.py
+++ b/cloud_mdir_sync/messages.py
@@ -281,6 +281,13 @@ class MessageDB(object):
self.alt_file_hashes[msg.content_hash].add(fn)
msg.fill_email_id()
+ def update_inode_cache(self, msg):
+ """After the message has been hardlinked or the times adjusted,
+ the inode cache needs to be updated with the new times"""
+ st = os.stat(msg.fn)
+ inode = (st.st_ino, st.st_size, st.st_mtime, st.st_ctime)
+ self.inode_hashes[inode] = msg.content_hash
+
def write_content(self, content_hash, dest_fn):
"""Make the filename dest_fn contain content_hash's content"""
assert content_hash in self.file_hashes