Exemple #1
0
        public void Crawl()
        {
            log_files.Clear();

            Queue pending = new Queue();

            pending.Enqueue(log_dir);

            while (pending.Count > 0)
            {
                string dir = (string)pending.Dequeue();

                foreach (string subdir in DirectoryWalker.GetDirectories(dir))
                {
                    pending.Enqueue(subdir);
                }

                foreach (FileInfo file in DirectoryWalker.GetFileInfos(dir))
                {
                    if (FileIsInteresting(file))
                    {
                        log_files.Add(file);
                    }
                }
            }
        }
Exemple #2
0
        private void CrawlProtocolDirectory(string proto_dir, bool index)
        {
            if (Inotify.Enabled)
            {
                Inotify.Subscribe(proto_dir, OnInotifyNewAccount, Inotify.EventType.Create);
            }

            // Walk through accounts
            foreach (string account_dir in DirectoryWalker.GetDirectories(proto_dir))
            {
                CrawlAccountDirectory(account_dir, index);
            }
        }
Exemple #3
0
        private void Crawl(bool index)
        {
            //queryable.IsIndexing = true;

            if (Inotify.Enabled)
            {
                Inotify.Subscribe(logs_dir, OnInotifyNewProtocol, Inotify.EventType.Create);
            }

            // Walk through protocol subdirs
            foreach (string proto_dir in DirectoryWalker.GetDirectories(logs_dir))
            {
                CrawlProtocolDirectory(proto_dir, index);
            }
        }
Exemple #4
0
        private void CrawlAccountDirectory(string account_dir, bool index)
        {
            if (Inotify.Enabled)
            {
                Inotify.Subscribe(account_dir, OnInotifyNewRemote, Inotify.EventType.Create);
            }

            // Walk through remote user conversations
            foreach (string remote_dir in DirectoryWalker.GetDirectories(account_dir))
            {
                if (remote_dir.IndexOf(".system") < 0)
                {
                    CrawlRemoteDirectory(remote_dir, index);
                }
            }
        }
        public OperaIndexer(OperaQueryable queryable, FileAttributesStore store, string root_dir)
        {
            this.attribute_store = store;
            this.queryable       = queryable;
            this.cache_dirs      = new ArrayList();

            // Try to find all cache dirs
            foreach (string dir in DirectoryWalker.GetDirectories(root_dir))
            {
                foreach (string file in DirectoryWalker.GetItems
                             (dir, new DirectoryWalker.FileFilter(IsCacheFile)))
                {
                    Inotify.Subscribe(dir, OnInotify, Inotify.EventType.MovedTo | Inotify.EventType.CloseWrite);
                    cache_dirs.Add(dir);
                }
            }
        }
        private void IndexDirectory(string directory)
        {
            Queue pending = new Queue();

            pending.Enqueue(directory);
            while (pending.Count > 0)
            {
                string dir = pending.Dequeue() as string;

                foreach (string subdir in DirectoryWalker.GetDirectories(dir))
                {
                    if (Shutdown.ShutdownRequested)
                    {
                        return;
                    }

                    pending.Enqueue(subdir);
                }

                if (Inotify.Enabled)
                {
                    inotify.Watch(dir,
                                  Inotify.EventType.Modify |
                                  Inotify.EventType.Create |
                                  Inotify.EventType.Delete |
                                  Inotify.EventType.MovedFrom |
                                  Inotify.EventType.MovedTo);
                }

                foreach (string file in DirectoryWalker.GetItems
                             (dir, new DirectoryWalker.FileFilter(Thunderbird.IsMorkFile)))
                {
                    if (Shutdown.ShutdownRequested)
                    {
                        return;
                    }

                    IndexFile(file);
                }
            }
        }
        private void Watch(string root)
        {
            Queue pending = new Queue();

            pending.Enqueue(root);

            while (pending.Count > 0)
            {
                string dir = (string)pending.Dequeue();

                foreach (string subdir in DirectoryWalker.GetDirectories(dir))
                {
                    if (Shutdown.ShutdownRequested)
                    {
                        return;
                    }

                    if (Inotify.Enabled)
                    {
                        Inotify.Subscribe(subdir, OnInotifyEvent,
                                          Inotify.EventType.Create
                                          | Inotify.EventType.Delete
                                          | Inotify.EventType.MovedTo);
                    }

                    pending.Enqueue(subdir);
                }

                Stopwatch watch = new Stopwatch();
                if (Debug)
                {
                    Logger.Log.Debug("Starting watch on {0}", dir);
                }
                watch.Start();
                foreach (string path in DirectoryWalker.GetItems(dir, new DirectoryWalker.FileFilter(IsSummary)))
                {
                    if (Shutdown.ShutdownRequested)
                    {
                        return;
                    }

                    FileInfo file = new FileInfo(path);

                    if (file.Name == "summary")
                    {
                        if (SummaryAddedEvent != null && FileIsInteresting(file))
                        {
                            SummaryAddedEvent(file, false);
                        }
                    }
                    else if (file.Extension == ".ev-summary")
                    {
                        string mbox_name = Path.Combine(file.DirectoryName,
                                                        Path.GetFileNameWithoutExtension(file.Name));
                        FileInfo mbox_file = new FileInfo(mbox_name);
                        if (MboxAddedEvent != null && FileIsInteresting(mbox_file))
                        {
                            MboxAddedEvent(mbox_file, false);
                        }
                    }
                }
                watch.Stop();
                if (Debug)
                {
                    Logger.Log.Debug("Crawled {0} in {1}", dir, watch);
                }
            }
        }