From 236c52bf8b6bf731d646199e6c7a379b141b9591 Mon Sep 17 00:00:00 2001
From: robk-tahoe <robk-tahoe@allmydata.com>
Date: Fri, 3 Oct 2008 10:13:09 -0700
Subject: [PATCH] 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.
---
 contrib/fuse/impl_a/tahoe_fuse.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

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
-- 
2.45.2