/// <summary> /// Create instance of USN journal service /// </summary> /// <param name="sources"></param> /// <param name="snapshot"></param> /// <param name="filter"></param> /// <param name="lastfilesetid"></param> /// <returns></returns> private UsnJournalService GetJournalService(IEnumerable <string> sources, ISnapshotService snapshot, IFilter filter, long lastfilesetid) { if (m_options.UsnStrategy == Options.OptimizationStrategy.Off) { return(null); } var journalData = m_database.GetChangeJournalData(lastfilesetid); var service = new UsnJournalService(sources, snapshot, filter, m_options.FileAttributeFilter, m_options.SkipFilesLargerThan, journalData, cancellationTokenSource.Token); foreach (var volumeData in service.VolumeDataList) { if (volumeData.IsFullScan) { if (volumeData.Exception == null || volumeData.Exception is UsnJournalSoftFailureException) { // soft fail Logging.Log.WriteInformationMessage(LOGTAG, "SkipUsnForVolume", "Performing full scan for volume \"{0}\": {1}", volumeData.Volume, volumeData.Exception?.Message); } else { if (m_options.UsnStrategy == Options.OptimizationStrategy.Auto) { Logging.Log.WriteInformationMessage(LOGTAG, "FailedToUseChangeJournal", "Failed to use change journal for volume \"{0}\": {1}", volumeData.Volume, volumeData.Exception.Message); } else if (m_options.UsnStrategy == Options.OptimizationStrategy.On) { Logging.Log.WriteWarningMessage(LOGTAG, "FailedToUseChangeJournal", volumeData.Exception, "Failed to use change journal for volume \"{0}\": {1}", volumeData.Volume, volumeData.Exception.Message); } else { throw volumeData.Exception; } } } } return(service); }