[gitg] Iterate all files within directory before recursing down



commit 83c9da393a3ba8daafb3bef06aa1c206655ee4bf
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sun Nov 8 16:48:50 2015 +0100

    Iterate all files within directory before recursing down
    
    This reduces the number of simultaneous open files

 gitg/gitg-recursive-monitor.vala |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gitg/gitg-recursive-monitor.vala b/gitg/gitg-recursive-monitor.vala
index e494f36..4f4c9e8 100644
--- a/gitg/gitg-recursive-monitor.vala
+++ b/gitg/gitg-recursive-monitor.vala
@@ -73,12 +73,14 @@ class RecursiveMonitor : Object
        private async void enumerate(File location) throws Error
        {
                var e = yield location.enumerate_children_async(FileAttribute.STANDARD_NAME + "," + 
FileAttribute.STANDARD_TYPE, FileQueryInfoFlags.NONE, Priority.DEFAULT, d_cancellable);
+               File[] allfiles = new File[0];
 
                while (true)
                {
                        var files = yield e.next_files_async(10, Priority.DEFAULT);
 
-                       if (files == null) {
+                       if (files == null)
+                       {
                                break;
                        }
 
@@ -86,12 +88,17 @@ class RecursiveMonitor : Object
                        {
                                if (f.get_file_type() == FileType.DIRECTORY)
                                {
-                                       add_submonitor(location.get_child(f.get_name()));
+                                       allfiles += location.get_child(f.get_name());
                                }
                        }
                }
 
                yield e.close_async(Priority.DEFAULT, d_cancellable);
+
+               foreach (var f in allfiles)
+               {
+                       add_submonitor(f);
+               }
        }
 
        private void add_submonitor(File location)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]