From 4dcbee6fdc7d67633edf562db641f9e4276bd15f Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Sat, 24 Aug 2019 14:10:03 -0600 Subject: [PATCH] tell the analyzer to stop fighting itself --- VirtualFileSystem/VirtualFileSystem.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/VirtualFileSystem/VirtualFileSystem.cs b/VirtualFileSystem/VirtualFileSystem.cs index 203bbe67..849228f4 100644 --- a/VirtualFileSystem/VirtualFileSystem.cs +++ b/VirtualFileSystem/VirtualFileSystem.cs @@ -19,6 +19,7 @@ namespace VFS public static VirtualFileSystem VFS; private Dictionary _files = new Dictionary(); private bool _disableDiskCache; + private volatile bool _isSyncing; public static string RootFolder { get; } public Dictionary> HashIndex { get; private set; } @@ -59,9 +60,20 @@ namespace VFS public void SyncToDisk() { if (!_disableDiskCache) - lock(this) { - _files.Values.OfType().ToBSON("vfs_cache.bson"); + Utils.Status("Syncing VFS Cache"); + lock (this) + { + try + { + _isSyncing = true; + _files.Values.OfType().ToBSON("vfs_cache.bson"); + } + finally + { + _isSyncing = false; + } + } } } @@ -252,7 +264,9 @@ namespace VFS new_files.Where(file => file.IsStaged).Do(file => file.Unstage()); f.FinishedIndexing = true; - SyncToDisk(); + + if (!_isSyncing) + SyncToDisk(); } public void Stage(IEnumerable files)