/// <summary> /// Enumerate all files listed as active, checking for status changes and take appropriate actions such as updating status /// in the FileSystemState, re-encrypting or deleting temporary plaintext copies. /// </summary> /// <param name="fileSystemState">The FileSystemState to enumerate and possibly update.</param> /// <param name="mode">Under what circumstances is the FileSystemState.Changed event raised.</param> /// <param name="progress">The ProgressContext to provide visual progress feedback via.</param> public static void CheckActiveFiles(this FileSystemState fileSystemState, ChangedEventMode mode, ProgressContext progress) { progress.NotifyLevelStart(); progress.AddTotal(fileSystemState.ActiveFileCount); fileSystemState.ForEach(mode, (ActiveFile activeFile) => { try { if (FileLock.IsLocked(activeFile.DecryptedFileInfo, activeFile.EncryptedFileInfo)) { return(activeFile); } if (OS.Current.UtcNow - activeFile.LastActivityTimeUtc <= new TimeSpan(0, 0, 5)) { return(activeFile); } activeFile = fileSystemState.CheckActiveFileActions(activeFile, progress); return(activeFile); } finally { progress.AddCount(1); } }); progress.NotifyLevelFinished(); }