directories: make initialization of the download cache lazy

If you open up a directory containing thousands of files, it currently computes the cache filename and checks for the cache file on disk immediately for each immutble file in that directory.  With this patch, it delays those steps until you try to do something with an immutable file that could use the cache.
This commit is contained in:
Zooko O'Whielacronx
2009-07-07 17:40:40 -07:00
parent 903005a528
commit c0d1e7deae
2 changed files with 12 additions and 7 deletions

View File

@ -428,9 +428,7 @@ class Client(node.Node, pollmixin.PollMixin):
if isinstance(u, LiteralFileURI):
node = LiteralFileNode(u, self) # LIT
else:
key = base32.b2a(u.storage_index)
cachefile = self.download_cache_dirman.get_file(key)
node = FileNode(u, self, cachefile) # CHK
node = FileNode(u, self, self.download_cache_dirman) # CHK
else:
assert IMutableFileURI.providedBy(u), u
node = MutableFileNode(self).init_from_uri(u)