From 45c64edc768eca0f2bca474f03d332a9ada70a8b Mon Sep 17 00:00:00 2001
From: Zooko O'Whielacronx <zooko@zooko.com>
Date: Thu, 7 Feb 2013 16:35:43 +0000
Subject: [PATCH] do not cache and re-use imm filenodes in nodemaker

fixes #1679
---
 src/allmydata/immutable/filenode.py | 2 ++
 src/allmydata/nodemaker.py          | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/allmydata/immutable/filenode.py b/src/allmydata/immutable/filenode.py
index 7def22c8..79e282d9 100644
--- a/src/allmydata/immutable/filenode.py
+++ b/src/allmydata/immutable/filenode.py
@@ -86,6 +86,8 @@ class CiphertextFileNode:
     def raise_error(self):
         pass
 
+    def is_mutable(self):
+        return False
 
     def check_and_repair(self, monitor, verify=False, add_lease=False):
         c = Checker(verifycap=self._verifycap,
diff --git a/src/allmydata/nodemaker.py b/src/allmydata/nodemaker.py
index c820c71c..d590bf5a 100644
--- a/src/allmydata/nodemaker.py
+++ b/src/allmydata/nodemaker.py
@@ -72,12 +72,12 @@ class NodeMaker:
             cap = uri.from_string(bigcap, deep_immutable=deep_immutable,
                                   name=name)
             node = self._create_from_single_cap(cap)
-            if node:
-                self._node_cache[memokey] = node  # note: WeakValueDictionary
-            else:
+            if node is None:
                 # don't cache UnknownNode
                 node = UnknownNode(writecap, readcap,
                                    deep_immutable=deep_immutable, name=name)
+            elif node.is_mutable():
+                self._node_cache[memokey] = node  # note: WeakValueDictionary
 
         if self.blacklist:
             si = node.get_storage_index()
-- 
2.45.2