diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2020-05-30 20:32:19 -0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2020-05-30 20:32:19 -0300 |
commit | d01fb937615bc4bc91cac8aa543bcc7e8476f870 (patch) | |
tree | c4304c8c93d926f1a32cd226f60add4a99f9ee71 /cloud_mdir_sync/messages.py | |
parent | d695a2eadde2d0799b5c663690212ec022d61c1c (diff) | |
download | cloud_mdir_sync-d01fb937615bc4bc91cac8aa543bcc7e8476f870.tar.gz cloud_mdir_sync-d01fb937615bc4bc91cac8aa543bcc7e8476f870.tar.bz2 cloud_mdir_sync-d01fb937615bc4bc91cac8aa543bcc7e8476f870.zip |
Keep the inode cache in sync when writing to the MailDir
MailDir writes cause the inode mtime and ctime to change which causes
the cache to become invalid. Update the mtime and ctime information after
changing it.
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'cloud_mdir_sync/messages.py')
-rw-r--r-- | cloud_mdir_sync/messages.py | 7 |
1 files changed, 7 insertions, 0 deletions
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 |