Browse Source

Fixed ConfigRuntime to actually load from disk properly

pull/46/head
Anairkoen Schno 4 years ago
parent
commit
8468f2e5d4
1 changed files with 7 additions and 10 deletions
  1. +7
    -10
      IPA.Loader/Config/ConfigRuntime.cs

+ 7
- 10
IPA.Loader/Config/ConfigRuntime.cs View File

@ -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);


Loading…
Cancel
Save