Commits

Steve Borho committed 5215e78

shlib: only send one shell notification per directory

This should improve the performance and possibly robustness
of large repository operations. It should not adversely effect
the shell overlays since it will get fewer refresh events and the
overlay code is already optimized to re-read entire directories.

  • Participants
  • Parent commits 7e34888
  • Tags 0.7.3

Comments (0)

Files changed (1)

             from win32com.shell import shell, shellcon
         except ImportError:
             return
+        dirs = []
         for path in paths:
             abspath = os.path.abspath(path)
-            pidl, ignore = shell.SHILCreateFromPath(abspath, 0)
+            if not os.path.isdir(abspath):
+                abspath = os.path.dirname(abspath)
+            if abspath not in dirs:
+                dirs.append(abspath)
+        # send notifications to deepest directories first
+        dirs.sort(lambda x, y: len(y) - len(x))
+        for dir in dirs:
+            pidl, ignore = shell.SHILCreateFromPath(dir, 0)
             if pidl is None:
                 continue
             shell.SHChangeNotify(shellcon.SHCNE_UPDATEITEM,