]> arthur.barton.de Git - bup.git/commitdiff
vfs.py: don't redundantly _populate_metadata for Dir()s.
authorRob Browning <rlb@defaultvalue.org>
Fri, 4 Apr 2014 20:55:37 +0000 (15:55 -0500)
committerRob Browning <rlb@defaultvalue.org>
Fri, 4 Apr 2014 20:55:39 +0000 (15:55 -0500)
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 <rlb@defaultvalue.org>
lib/bup/vfs.py

index 85b4c204c2f261fb1e984a7b450d38af4b22adc6..728a7a01f469219957ca06419e7127351508557e 100644 (file)
@@ -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 = {}