// Track renames so that files whose names are changed can be updated in the processed files list. private void Watcher_Renamed(object sender, RenamedEventArgs args) { bool oldMatch = MatchesFilter(args.OldFullPath); bool newMatch = MatchesFilter(args.FullPath); if (!oldMatch && !newMatch) { return; } m_processingQueue.Add(() => { if (oldMatch && m_touchedFiles.Remove(args.OldFullPath) && newMatch) { m_touchedFiles.Add(args.FullPath, File.GetLastWriteTimeUtc(args.FullPath)); } if (oldMatch && m_processedFiles.Remove(args.OldFullPath)) { m_processedFiles.Add(args.FullPath); } if (!oldMatch && newMatch) { TouchLockAndProcess(args.FullPath); } }); }
public void RemoveTest() { using (FileBackedHashSet <int> hashSet = new FileBackedHashSet <int>()) { hashSet.Add(0); Assert.IsTrue(hashSet.Contains(0)); hashSet.Remove(0); Assert.IsFalse(hashSet.Contains(0)); Assert.AreEqual(hashSet.Count, 0); } }
public void RemoveTest() { using (FileBackedHashSet<int> hashSet = new FileBackedHashSet<int>()) { hashSet.Add(0); Assert.IsTrue(hashSet.Contains(0)); hashSet.Remove(0); Assert.IsFalse(hashSet.Contains(0)); Assert.AreEqual(hashSet.Count, 0); } }
public void CompactTest() { using (FileBackedHashSet <int> hashSet = new FileBackedHashSet <int>()) { for (int i = 0; i < 10000; i += 4) { hashSet.Add(i); if (i % 100 == 0) { hashSet.Remove(i); } if (i % 400 == 0) { hashSet.Add(i); } } hashSet.Compact(); for (int i = 0; i < 10000; i++) { if (i % 400 == 0) { Assert.IsTrue(hashSet.Contains(i)); } else if (i % 100 == 0) { Assert.IsFalse(hashSet.Contains(i)); } else if (i % 4 == 0) { Assert.IsTrue(hashSet.Contains(i)); } else { Assert.IsFalse(hashSet.Contains(i)); } } } }
public void CompactTest() { using (FileBackedHashSet<int> hashSet = new FileBackedHashSet<int>()) { for (int i = 0; i < 10000; i += 4) { hashSet.Add(i); if (i % 100 == 0) hashSet.Remove(i); if (i % 400 == 0) hashSet.Add(i); } hashSet.Compact(); for (int i = 0; i < 10000; i++) { if (i % 400 == 0) Assert.IsTrue(hashSet.Contains(i)); else if (i % 100 == 0) Assert.IsFalse(hashSet.Contains(i)); else if (i % 4 == 0) Assert.IsTrue(hashSet.Contains(i)); else Assert.IsFalse(hashSet.Contains(i)); } } }