コード例 #1
0
        /// <inheritdoc />
        public void OnNext(ChangedFileIdInfo value)
        {
            Entry entry;

            if (m_entries.TryGetValue(value.FileIdAndVolumeId, out entry))
            {
                if (value.UsnRecord.Usn > entry.Usn)
                {
                    switch (value.UsnRecord.Reason.LinkImpact())
                    {
                    case LinkImpact.None:
                    case LinkImpact.SingleLink:
                        // Update with new USN.
                        m_entries.TryUpdate(value.FileIdAndVolumeId, entry.WithNewUsn(value.UsnRecord.Usn), entry);
                        ++m_observerData.UpdatedUsnEntryByJournalScanningCount;
                        break;

                    case LinkImpact.AllLinks:
                        // Remove from mapping.
                        m_entries.TryRemove(value.FileIdAndVolumeId, out entry);
                        ++m_observerData.RemovedEntryByJournalScanningCount;
                        break;
                    }
                }
            }
        }
コード例 #2
0
        /// <inheritdoc />
        public void OnNext(ChangedFileIdInfo value)
        {
            Entry entry;

            if (m_entries.TryGetValue(value.FileIdAndVolumeId, out entry))
            {
                if (value.UsnRecord.Usn > entry.Usn)
                {
                    switch (value.UsnRecord.Reason.LinkImpact())
                    {
                    case LinkImpact.None:
                    case LinkImpact.SingleLink:
                        // Update with new USN only if entry's USN matches previously tracked USN or the file id's entry was updated before.
                        // We track whether file id's entry was updated or not because some operations can have more than one USN records.
                        // For example, file renaming has at least two records, "RenameOldName" followed by "RenameNewName".
                        // Another example is timestamp modification can come with "BasicInfoChange" followed by "BasicInfoChange|Close".
                        // If the entry is updated by the first record, and we don't keep track that fact, then the new record will
                        // invalidate the updated entry because it will have more up-to-date USN.
                        if (m_updatedFileId.Contains(value.FileIdAndVolumeId) || value.LastTrackedUsn == entry.Usn)
                        {
                            m_entries.TryUpdate(value.FileIdAndVolumeId, entry.WithNewUsn(value.UsnRecord.Usn), entry);
                            m_updatedFileId.Add(value.FileIdAndVolumeId);
                            ++m_observerData.UpdatedUsnEntryByJournalScanningCount;
                        }
                        break;

                    case LinkImpact.AllLinks:
                        // Remove from mapping.
                        m_entries.TryRemove(value.FileIdAndVolumeId, out _);
                        ++m_observerData.RemovedEntryByJournalScanningCount;
                        break;
                    }
                }
            }
        }
コード例 #3
0
 /// <inheritdoc />
 public void OnNext(ChangedFileIdInfo value)
 {
 }