mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
Allow retrying when writing config json
This commit is contained in:
@@ -72,7 +72,21 @@ namespace Flowframes.IO
|
||||
return;
|
||||
|
||||
SortedDictionary<string, string> cachedValuesSorted = new SortedDictionary<string, string>(CachedValues);
|
||||
|
||||
// Retry every 100ms up to 10 times in case of an exception
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllText(configPath, JsonConvert.SerializeObject(cachedValuesSorted, Formatting.Indented));
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Failed to write config{(i < 10 ? ", will retry." : " and out of retries!")} {e.Message}", true);
|
||||
Task.Delay(100).Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Reload()
|
||||
|
||||
Reference in New Issue
Block a user