Directory UI: Only stat() directories that couldn't be opened, to reduce the number...
authorMatt Nordhoff <mnordhoff@mattnordhoff.com>
Tue, 5 May 2009 18:37:26 +0000 (18:37 +0000)
committerMatt Nordhoff <mnordhoff@mattnordhoff.com>
Tue, 5 May 2009 18:37:26 +0000 (18:37 +0000)
Jelmer did this with his transport work, but I didn't realize why, so I took it out. Whoops.

loggerhead/controllers/directory_ui.py

index 59b8b6f..0dd9ab8 100644 (file)
@@ -65,8 +65,7 @@ class DirectoryUI(TemplatedBranchView):
 
     def get_values(self, path, kwargs, response):
         listing = [d for d in self.transport.list_dir('.')
-                   if not d.startswith('.')
-                   and stat.S_ISDIR(self.transport.stat(d).st_mode)]
+                   if not d.startswith('.')]
         listing.sort(key=lambda x: x.lower())
         dirs = []
         parity = 0
@@ -74,6 +73,8 @@ class DirectoryUI(TemplatedBranchView):
             try:
                 b = branch.Branch.open_from_transport(self.transport.clone(d))
             except:
+                if not stat.S_ISDIR(self.transport.stat(d).st_mode):
+                    continue
                 b = None
             dirs.append(DirEntry(d, parity, b))
             parity = 1 - parity