public void Unload() { // cut off the LRU cache LruCache = LruCache.GetRange(0, Math.Min(LruCache.Count, MaxBinaryCount)); foreach (var CachedBinary in Directory.EnumerateFiles(BinaryCacheFolderPath)) { string PeHash = GetBinaryHash(CachedBinary); if (LruCache.Find(Hash => (Hash == PeHash)) == null) { // Force map unloading before deleting file if (BinaryDatabase.ContainsKey(PeHash)) { BinaryDatabase[PeHash].Unload(); } try { File.Delete(CachedBinary); } catch (System.UnauthorizedAccessException uae) { // The BinaryCache is shared among serveral Dependencies.exe instance // so only the last one alive can clear the cache. Debug.WriteLine("[BinaryCache] Could not unload file {0:s} : {1:s} ", CachedBinary, uae); } } } // flush the cache BinaryDatabase.Clear(); }
public void Unload() { // cut off the LRU cache LruCache = LruCache.GetRange(0, Math.Min(LruCache.Count, MaxBinaryCount)); foreach (var CachedBinary in Directory.EnumerateFiles(BinaryCacheFolderPath)) { string PeHash = GetBinaryHash(CachedBinary); if (LruCache.Find(Hash => (Hash == PeHash)) == null) { // Force map unloading before deleting file if (BinaryDatabase.ContainsKey(PeHash)) { BinaryDatabase[PeHash].Unload(); } File.Delete(CachedBinary); } } // flush the cache BinaryDatabase.Clear(); }