private void ProcessIncrementalUpdate(AssetIndexChangeSet changeset)
        {
            var updates  = CreateArtifacts(changeset.updated);
            var taskName = $"Updating {settings.name.ToLowerInvariant()} search index";

            Interlocked.Increment(ref m_UpdateTasks);
            m_CurrentUpdateTask = new Task("Update", taskName, (task, data) => MergeDocuments(task, data, changeset), updates.Length, this);
            ResolveArtifacts(updates, null, m_CurrentUpdateTask, false);
        }
        private void IncrementalUpdate(AssetIndexChangeSet changeset)
        {
            if (!this)
            {
                return;
            }

            m_UpdateQueue.Add(changeset);
            ProcessIncrementalUpdates();
        }
        private void OnContentRefreshed(string[] updated, string[] removed, string[] moved)
        {
            if (!this || settings.options.disabled)
            {
                return;
            }
            var changeset = new AssetIndexChangeSet(updated, removed, moved, p => !index.SkipEntry(p, true));

            if (changeset.empty)
            {
                return;
            }
            IncrementalUpdate(changeset);
        }
        private void MergeDocuments(Task task, TaskData data, AssetIndexChangeSet changeset)
        {
            if (task.canceled || task.error != null)
            {
                ResolveIncrementalUpdate(task);
                return;
            }

            var baseScore      = settings.baseScore;
            var indexName      = settings.name.ToLowerInvariant();
            var saveIndexCache = !Utils.IsRunningTests();
            var savePath       = GetBackupIndexPath(createDirectory: true);

            task.Report("Merging changes to index...");
            task.RunThread(() =>
            {
                index.Merge(changeset.removed, data.combinedIndex, baseScore,
                            (di, indexer, count) => OnDocumentMerged(task, indexer, indexName, di, count));
                if (saveIndexCache)
                {
                    SaveIndex(savePath, index.SaveBytes(), task);
                }
            }, () => ResolveIncrementalUpdate(task));
        }