private void DirectoryChangeWatcherErrorTask()
        {
            // Ingore all changes
            _pathsChangedQueue.DequeueAll();

            // Rescan all projects from scratch.
            RecomputeGraph(null /* force rescan*/);
        }
Esempio n. 2
0
        private void DirectoryChangeWatcherOnError(Exception exception)
        {
            Logger.LogInfo("File change events error: queuing a full file system rescan");
            // Ingore all changes
            _pathsChangedQueue.DequeueAll();

            // Rescan all projects from scratch.
            _fileRegistrationTracker.Refresh();
        }
        public IList <FileRegistrationEntry> DequeueAll()
        {
            var allEntries = _queue.DequeueAll();

            if (allEntries.Count == 0)
            {
                return(allEntries);
            }

            // Merge entries into a shorter list
            var singleEntries = new Dictionary <FullPath, FileRegistrationKind>();

            foreach (var entry in allEntries)
            {
                FileRegistrationKind previousKind;
                if (singleEntries.TryGetValue(entry.Path, out previousKind))
                {
                    // Path has been (un)registered, merge both kinds together
                    switch (previousKind)
                    {
                    case FileRegistrationKind.Register:
                        switch (entry.Kind)
                        {
                        case FileRegistrationKind.Register:
                            // Register + Register = leave as is
                            break;

                        case FileRegistrationKind.Unregister:
                            // Register + Unregister = remove entry
                            singleEntries.Remove(entry.Path);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                        break;

                    case FileRegistrationKind.Unregister:
                        switch (entry.Kind)
                        {
                        case FileRegistrationKind.Register:
                            // Unregister + Register = remove entry
                            singleEntries.Remove(entry.Path);
                            break;

                        case FileRegistrationKind.Unregister:
                            // Unregister + Unregister = leave as is
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
                else
                {
                    // Path is not registered, simply add the entry.
                    singleEntries.Add(entry.Path, entry.Kind);
                }
            }
            return(singleEntries.Select(x => new FileRegistrationEntry(x.Key, x.Value)).ToList());
        }