Browse Source

Also abort legacy save thread, null check config Store

master
Meivyn 3 months ago
parent
commit
8eee59db27
No known key found for this signature in database GPG Key ID: 8BDD3E48158B2F71
2 changed files with 8 additions and 9 deletions
  1. +6
    -7
      IPA.Loader/Config/ConfigRuntime.cs
  2. +2
    -2
      IPA/Program.cs

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

@ -27,10 +27,8 @@ namespace IPA.Config
private static readonly ConcurrentBag<Config> configs = new();
private static readonly AutoResetEvent configsChangedWatcher = new(false);
private static readonly ConcurrentDictionary<DirectoryInfo, FileSystemWatcher> watchers
= new ConcurrentDictionary<DirectoryInfo, FileSystemWatcher>(new DirInfoEqComparer());
private static readonly ConcurrentDictionary<FileSystemWatcher, ConcurrentBag<Config>> watcherTrackConfigs
= new ConcurrentDictionary<FileSystemWatcher, ConcurrentBag<Config>>();
private static readonly ConcurrentDictionary<DirectoryInfo, FileSystemWatcher> watchers = new(new DirInfoEqComparer());
private static readonly ConcurrentDictionary<FileSystemWatcher, ConcurrentBag<Config>> watcherTrackConfigs = new();
private static BlockingCollection<IConfigStore> requiresSave = new();
private static SingleThreadTaskScheduler loadScheduler;
private static TaskFactory loadFactory;
@ -82,13 +80,14 @@ namespace IPA.Config
loadScheduler.Join(); // we can wait for the loads to finish
saveThread.Abort(); // eww, but i don't like any of the other potential solutions
legacySaveThread.Abort();
SaveAll();
requiresSave.Dispose();
requiresSave = null;
}
catch
catch
{
}
}
@ -237,7 +236,7 @@ namespace IPA.Config
{
try
{
Save(configs.First((c) => ReferenceEquals(c.Store.WriteSyncObject, item.WriteSyncObject)));
Save(configs.First((c) => c.Store != null && ReferenceEquals(c.Store.WriteSyncObject, item.WriteSyncObject)));
}
catch (ThreadAbortException)
{
@ -263,7 +262,7 @@ namespace IPA.Config
{
while (true)
{
var configArr = configs.Where(c => c.Store != null).Where(c => c.Store.SyncObject != null).ToArray();
var configArr = configs.Where(c => c.Store?.SyncObject != null).ToArray();
int index = -1;
try
{


+ 2
- 2
IPA/Program.cs View File

@ -334,9 +334,9 @@ namespace IPA
LineBack();
ClearLine();
}
catch (Exception ex)
catch (IOException)
{
// Might throw IOException due to an invalid handle when accessing IsConsole from a MSBuild task.
// Might throw due to an invalid handle when accessing IsConsole from a MSBuild task.
}
Console.WriteLine(@"Copying {0}", targetFile.FullName);


Loading…
Cancel
Save