mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Improve global config events handling, #520
This commit is contained in:
@@ -316,7 +316,7 @@ namespace ArchiSteamFarm {
|
||||
bot.OnNewConfigLoaded(new BotConfigEventArgs(BotConfig.Load(e.FullPath))).Forget();
|
||||
}
|
||||
|
||||
private static void OnCreated(object sender, FileSystemEventArgs e) {
|
||||
private static async void OnCreated(object sender, FileSystemEventArgs e) {
|
||||
if ((sender == null) || (e == null)) {
|
||||
ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e));
|
||||
return;
|
||||
@@ -327,6 +327,12 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
if (botName.Equals(SharedInfo.ASF)) {
|
||||
ArchiLogger.LogGenericInfo(Strings.GlobalConfigChanged);
|
||||
await RestartOrExit().ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
CreateBot(botName).Forget();
|
||||
}
|
||||
|
||||
@@ -342,6 +348,13 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
if (botName.Equals(SharedInfo.ASF)) {
|
||||
// Some editors might decide to delete file and re-create it in order to modify it
|
||||
// If that's the case, we wait for maximum of 5 seconds before shutting down
|
||||
await Task.Delay(5000).ConfigureAwait(false);
|
||||
if (File.Exists(e.FullPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArchiLogger.LogGenericError(Strings.ErrorGlobalConfigRemoved);
|
||||
await Program.Exit(1).ConfigureAwait(false);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user