Browse Source

Added handling for potention IOExceptions when saving and loading configs

piracy-check 3.10.2
Anairkoen Schno 6 years ago
parent
commit
66f1a12a62
1 changed files with 40 additions and 5 deletions
  1. +40
    -5
      IPA.Loader/Loader/PluginComponent.cs

+ 40
- 5
IPA.Loader/Loader/PluginComponent.cs View File

@ -44,7 +44,16 @@ namespace IPA.Loader
SceneManager.sceneUnloaded += OnSceneUnloaded;
foreach (var provider in PluginManager.configProviders)
if (provider.Key.HasChanged) provider.Key.Save();
if (provider.Key.HasChanged)
try
{
provider.Key.Save();
}
catch (Exception e)
{
Logging.Logger.log.Error("Error when trying to save config");
Logging.Logger.log.Error(e);
}
}
void Update()
@ -60,11 +69,28 @@ namespace IPA.Loader
foreach (var provider in PluginManager.configProviders)
{
if (provider.Key.HasChanged) provider.Key.Save();
if (provider.Key.HasChanged)
try
{
provider.Key.Save();
}
catch (Exception e)
{
Logging.Logger.log.Error("Error when trying to save config");
Logging.Logger.log.Error(e);
}
else if (provider.Key.LastModified > provider.Value.Value)
{
provider.Key.Load(); // auto reload if it changes
provider.Value.Value = provider.Key.LastModified;
try
{
provider.Key.Load(); // auto reload if it changes
provider.Value.Value = provider.Key.LastModified;
}
catch (Exception e)
{
Logging.Logger.log.Error("Error when trying to load config");
Logging.Logger.log.Error(e);
}
}
}
}
@ -93,7 +119,16 @@ namespace IPA.Loader
ipaPlugins.OnApplicationQuit();
foreach (var provider in PluginManager.configProviders)
if (provider.Key.HasChanged) provider.Key.Save();
if (provider.Key.HasChanged)
try
{
provider.Key.Save();
}
catch (Exception e)
{
Logging.Logger.log.Error("Error when trying to save config");
Logging.Logger.log.Error(e);
}
quitting = true;
}


Loading…
Cancel
Save