LauncherQueryable pretty much does all that LauncherCrawler does, with some minor differences. This patch merges the two, and removes the need for LauncherCrawler. I tested with and without inotify, and all 125 launchers are indexed (which is the same number before I wrote this patch). Index: beagled/LauncherQueryable/LauncherQueryable.cs =================================================================== RCS file: /cvs/gnome/beagle/beagled/LauncherQueryable/LauncherQueryable.cs,v retrieving revision 1.14 diff -u -B -p -r1.14 LauncherQueryable.cs --- beagled/LauncherQueryable/LauncherQueryable.cs 9 May 2005 21:52:54 -0000 1.14 +++ beagled/LauncherQueryable/LauncherQueryable.cs 14 May 2005 19:59:16 -0000 @@ -45,7 +45,6 @@ namespace Beagle.Daemon.LauncherQueryabl string home; FileStream LauncherDB; int polling_interval_in_hours = 1; - LauncherCrawler crawler; public LauncherQueryable () : base ("LauncherIndex") { @@ -78,18 +77,9 @@ namespace Beagle.Daemon.LauncherQueryabl Stopwatch timer = new Stopwatch (); timer.Start (); - if (Inotify.Enabled) { + if (Inotify.Enabled) Inotify.Event += OnInotifyEvent; - log.Info ("Scanning Launchers"); - int launchers_found = 0; - foreach (String dir in Dirs) - launchers_found += Watch (dir); - - log.Info ("Found {0} Launchers in {1}", launchers_found, timer); - } - - this.crawler = new LauncherCrawler (Dirs); Crawl (); if (!Inotify.Enabled) { @@ -104,10 +94,13 @@ namespace Beagle.Daemon.LauncherQueryabl private void Crawl () { - this.crawler.Crawl (); - - foreach (FileInfo file in crawler.Launchers) - IndexLauncher (file, Scheduler.Priority.Delayed); + log.Info ("Scanning Launchers"); + Stopwatch timer = new Stopwatch (); + int launchers_found = 0; + foreach (String dir in Dirs) + launchers_found += CrawlLaunchers (dir); + + log.Info ("Found {0} Launchers in {1}", launchers_found, timer); } private void CrawlHook (Scheduler.Task task) @@ -117,7 +110,10 @@ namespace Beagle.Daemon.LauncherQueryabl task.TriggerTime = DateTime.Now.AddHours (this.polling_interval_in_hours); } - private int Watch (string path) + // Crawl the specified directory and all subdirectories, indexing all + // discovered launchers. If Inotify is available, every directory + // scanned will be added to the watched list. + private int CrawlLaunchers (string path) { DirectoryInfo root = new DirectoryInfo (path); if (! root.Exists) @@ -129,8 +125,12 @@ namespace Beagle.Daemon.LauncherQueryabl while (queue.Count > 0) { DirectoryInfo dir = queue.Dequeue () as DirectoryInfo; - int wd = Inotify.Watch (dir.FullName, Inotify.EventType.Create | Inotify.EventType.Modify); - watched [wd] = true; + + if (Inotify.Enabled) { + int wd = Inotify.Watch (dir.FullName, Inotify.EventType.Create | Inotify.EventType.Modify); + watched [wd] = true; + } + foreach (FileInfo file in dir.GetFiles ()) { IndexLauncher (file, Scheduler.Priority.Delayed); ++fileCount; @@ -155,7 +155,7 @@ namespace Beagle.Daemon.LauncherQueryabl string fullPath = Path.Combine (path, subitem); if ((type & Inotify.EventType.Create) != 0 && (type & Inotify.EventType.IsDirectory) != 0) { - Watch (fullPath); + CrawlLaunchers (fullPath); return; } if ((type & Inotify.EventType.Modify) != 0) {