Exemplo n.º 1
0
        private bool Process()
        {
            Queue tmp = new Queue();

            lock (queue.SyncRoot) {
                while (queue.Count > 0)
                {
                    Event ev   = (Event)queue.Dequeue();
                    long  size = Thunderbird.GetFileSize(Path.Combine(ev.Path, ev.Subitem));

                    if (Thunderbird.Debug)
                    {
                        Logger.Log.Debug("EVENT: {0} ({1}) [{2}, {3}]",
                                         Path.Combine(ev.Path, ev.Subitem).ToString(), ev.Type, ev.CurrentFileSize, size);
                    }

                    if (size != ev.CurrentFileSize)
                    {
                        ev.OldFileSize     = ev.CurrentFileSize;
                        ev.CurrentFileSize = size;
                        tmp.Enqueue(ev);
                        continue;
                    }

                    OnInotifyEvent(ev);
                }

                while (tmp.Count > 0)
                {
                    queue.Enqueue(tmp.Dequeue());
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public void IndexFile(string file)
        {
            TB.Account account = GetParentAccount(file);

            if (account == null || supported_types [account.Type] == null || Thunderbird.GetFileSize(file) < 1)
            {
                return;
            }

            object[] param = new object[] { this, account, file };
            ThunderbirdIndexableGenerator generator = Activator.CreateInstance(
                (Type)supported_types [account.Type], param) as ThunderbirdIndexableGenerator;

            AddIIndexableTask(generator, file);
        }
Exemplo n.º 3
0
        private void OnInotify(Inotify.Watch watch,
                               string path,
                               string subitem,
                               string srcpath,
                               Inotify.EventType type)
        {
            if (subitem == null)
            {
                return;
            }

            // Unsubscribe to directories that have been removed
            if ((type & Inotify.EventType.Delete) != 0 && (type & Inotify.EventType.IsDirectory) != 0)
            {
                watch.Unsubscribe();
            }

            lock (queue.SyncRoot) {
                bool found = false;
                for (int i = 0; i < queue.Count; i++)
                {
                    Event ev = (Event)queue.Dequeue();

                    if (ev.Path == path && ev.Subitem == subitem && ev.Srcpath == srcpath)
                    {
                        found   = true;
                        ev.Type = (ev.Type | type);
                        queue.Enqueue(ev);
                        break;
                    }

                    queue.Enqueue(ev);
                }

                if (!found)
                {
                    queue.Enqueue(new Event(watch, path, subitem, srcpath,
                                            type, -1, Thunderbird.GetFileSize(Path.Combine(path, subitem))));
                }
            }
        }