示例#1
0
        override protected void DoTaskReal()
        {
            DirectoryModel dir;

            lock (big_lock) {
                if (to_be_crawled.Count == 0)
                {
                    DoneCrawling();
                    return;
                }
                dir = to_be_crawled.Dequeue() as DirectoryModel;

                if (FileSystemQueryable.Debug)
                {
                    Log.Debug("Running tree crawl task");
                }

                SetIsActive(true, dir);
            }

            LuceneQueryable queryable = (LuceneQueryable)Source;

            if (dir.IsAttached)
            {
                if (FileSystemQueryable.Debug)
                {
                    Logger.Log.Debug("Scanning '{0}' for subdirectories", dir.FullName);
                }

                try {
                    foreach (string name in DirectoryWalker.GetDirectoryNames(dir.FullName))
                    {
                        string path;
                        path = Path.Combine(dir.FullName, name);
                        if (!FileSystem.IsSpecialFile(path))
                        {
                            handler(dir, name);
                        }
                    }
                } catch (DirectoryNotFoundException ex) {
                    Logger.Log.Debug("Couldn't scan '{0}' for subdirectories", dir.FullName);
                }
            }

            lock (big_lock) {
                if (to_be_crawled.Count != 0)
                {
                    Reschedule = true;
                }
                else
                {
                    DoneCrawling();
                }
            }
        }