From 8468f2e5d450c3d397750996b25ebf8d7d678a40 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sun, 15 Dec 2019 23:36:51 -0600 Subject: [PATCH] Fixed ConfigRuntime to actually load from disk properly --- IPA.Loader/Config/ConfigRuntime.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/IPA.Loader/Config/ConfigRuntime.cs b/IPA.Loader/Config/ConfigRuntime.cs index 57b7c931..8266cfe9 100644 --- a/IPA.Loader/Config/ConfigRuntime.cs +++ b/IPA.Loader/Config/ConfigRuntime.cs @@ -103,17 +103,15 @@ namespace IPA.Config var dir = config.File.Directory; if (!watchers.TryGetValue(dir, out var watcher)) { // create the watcher - watcher = new FileSystemWatcher(dir.FullName, ""); - var newWatcher = watchers.GetOrAdd(dir, watcher); - if (watcher != newWatcher) - { // if someone else beat us to adding, delete ours and switch to that new one - watcher.Dispose(); - watcher = newWatcher; - } + watcher = watchers.GetOrAdd(dir, dir => new FileSystemWatcher(dir.FullName)); watcher.NotifyFilter = NotifyFilters.FileName - | NotifyFilters.LastWrite; + | NotifyFilters.LastWrite + | NotifyFilters.Size + | NotifyFilters.LastAccess + | NotifyFilters.Attributes + | NotifyFilters.CreationTime; watcher.Changed += FileChangedEvent; watcher.Created += FileChangedEvent; @@ -130,7 +128,6 @@ namespace IPA.Config bag.Add(config); watcher.EnableRaisingEvents = true; - } private static void EnsureWritesSane(Config config) @@ -147,7 +144,7 @@ namespace IPA.Config if (!watcherTrackConfigs.TryGetValue(watcher, out var bag)) return; var config = bag.FirstOrDefault(c => c.File.FullName == e.FullPath); - if (config != null && Interlocked.Decrement(ref config.Writes) + 1 > 0) + if (config != null && Interlocked.Decrement(ref config.Writes) + 1 <= 0) { EnsureWritesSane(config); TriggerFileLoad(config);