[gitg] Make monitor file enumeration async



commit b2cda3723aa1f3b162a746369b032a173f3040f2
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sun Aug 9 18:06:18 2015 +0200

    Make monitor file enumeration async

 gitg/gitg-recursive-monitor.vala |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/gitg/gitg-recursive-monitor.vala b/gitg/gitg-recursive-monitor.vala
index e3b65fd..e0c150f 100644
--- a/gitg/gitg-recursive-monitor.vala
+++ b/gitg/gitg-recursive-monitor.vala
@@ -62,25 +62,34 @@ class RecursiveMonitor : Object
 
                d_cancellable = new Cancellable();
 
-               location.enumerate_children_async.begin(FileAttribute.STANDARD_NAME + "," + 
FileAttribute.STANDARD_TYPE, FileQueryInfoFlags.NONE, Priority.DEFAULT, d_cancellable, (obj, res) => {
-                       FileEnumerator enumerator;
-
+               enumerate.begin(location, (obj, res) => {
                        try
                        {
-                               enumerator = location.enumerate_children_async.end(res);
+                               enumerate.end(res);
+                       } catch {}
+               });
+       }
 
-                               FileInfo? info;
+       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);
+
+               while (true)
+               {
+                       var files = yield e.next_files_async(10, Priority.DEFAULT);
 
-                               while ((info = enumerator.next_file()) != null)
+                       if (files == null) {
+                               break;
+                       }
+
+                       foreach (var f in files)
+                       {
+                               if (f.get_file_type() == FileType.DIRECTORY)
                                {
-                                       if (info.get_file_type() == FileType.DIRECTORY)
-                                       {
-                                               add_submonitor(location.get_child(info.get_name()));
-                                       }
+                                       add_submonitor(location.get_child(f.get_name()));
                                }
                        }
-                       catch {}
-               });
+               }
        }
 
        private void add_submonitor(File location)


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