From: robk-tahoe Date: Fri, 3 Oct 2008 17:13:09 +0000 (-0700) Subject: fuse/impl_a: fix a suspected bug in caching X-Git-Url: https://git.rkrishnan.org/vdrive/configuration.txt?a=commitdiff_plain;h=236c52bf8b6bf731d646199e6c7a379b141b9591;p=tahoe-lafs%2Ftahoe-lafs.git fuse/impl_a: fix a suspected bug in caching from my examination of the tahoe_fuse ('impl_a') code, it looks like the intention is to cache the file contents in memory while it's open, since it does in fact do that. however it looks like it also ignored that cache entirely, and made an individual tahoe webapi GET request for each and every read() operation regardless of the relative size of the read block and the file in question. this changes that to make read() use the data in memory rather than fetch the data over again. if there's something more subtle going on, please let me know. --- diff --git a/contrib/fuse/impl_a/tahoe_fuse.py b/contrib/fuse/impl_a/tahoe_fuse.py index c9553d3c..63868301 100644 --- a/contrib/fuse/impl_a/tahoe_fuse.py +++ b/contrib/fuse/impl_a/tahoe_fuse.py @@ -201,9 +201,11 @@ class TahoeFS (fuse.Fuse): return self.rootdir.resolve_path(parts) def _get_contents(self, path): - node = self._get_node(path) - contents = node.open().read() - self.filecontents[path] = contents + contents = self.filecontents.get(path) + if contents is None: + node = self._get_node(path) + contents = node.open().read() + self.filecontents[path] = contents return contents @trace_calls