From: Rob Browning Date: Fri, 4 Apr 2014 20:55:37 +0000 (-0500) Subject: vfs.py: don't redundantly _populate_metadata for Dir()s. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=dd9e22dc64b2716caec076ebbee65400c4c9f957;p=packages%2Fb%2Fbup.git vfs.py: don't redundantly _populate_metadata for Dir()s. This fix should significantly improve performance. Without it, every call to node.metadata() caused the VFS to read the entire .bupm file in order to (re)initialize the metadata for every entry in the directory. Don't do that. I thought I'd already implemented this, but apparently only in my head. Signed-off-by: Rob Browning --- diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py index 85b4c20..728a7a0 100644 --- a/lib/bup/vfs.py +++ b/lib/bup/vfs.py @@ -401,15 +401,18 @@ class Dir(Node): self._bupm = None def _populate_metadata(self): + if self._metadata: + return if not self._subs: self._mksubs() if not self._bupm: return meta_stream = self._bupm.open() - self._metadata = metadata.Metadata.read(meta_stream) + dir_meta = metadata.Metadata.read(meta_stream) for sub in self: if not stat.S_ISDIR(sub.mode): sub._metadata = metadata.Metadata.read(meta_stream) + self._metadata = dir_meta def _mksubs(self): self._subs = {}