mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-06 17:10:13 +00:00
committed by
GitHub
parent
9163b57c3e
commit
af4a64b99e
@@ -580,6 +580,28 @@ public static class ASF {
|
||||
await OnCreatedKeysFile(name, fullPath).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static async Task OnConfigChanged() {
|
||||
string globalConfigFile = GetFilePath(EFileType.Config);
|
||||
|
||||
if (string.IsNullOrEmpty(globalConfigFile)) {
|
||||
throw new InvalidOperationException(nameof(globalConfigFile));
|
||||
}
|
||||
|
||||
(GlobalConfig? globalConfig, _) = await GlobalConfig.Load(globalConfigFile).ConfigureAwait(false);
|
||||
|
||||
if (globalConfig == null) {
|
||||
// Invalid config file, we allow user to fix it without destroying the ASF instance right away
|
||||
return;
|
||||
}
|
||||
|
||||
if (globalConfig == GlobalConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArchiLogger.LogGenericInfo(Strings.GlobalConfigChanged);
|
||||
await RestartOrExit().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static async void OnCreated(object sender, FileSystemEventArgs e) {
|
||||
ArgumentNullException.ThrowIfNull(sender);
|
||||
ArgumentNullException.ThrowIfNull(e);
|
||||
@@ -666,8 +688,7 @@ public static class ASF {
|
||||
}
|
||||
|
||||
if (botName.Equals(SharedInfo.ASF, StringComparison.OrdinalIgnoreCase)) {
|
||||
ArchiLogger.LogGenericInfo(Strings.GlobalConfigChanged);
|
||||
await RestartOrExit().ConfigureAwait(false);
|
||||
await OnConfigChanged().ConfigureAwait(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1402,16 +1402,13 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
|
||||
string configFile = GetFilePath(EFileType.Config);
|
||||
|
||||
if (string.IsNullOrEmpty(configFile)) {
|
||||
ArchiLogger.LogNullError(configFile);
|
||||
|
||||
return;
|
||||
throw new InvalidOperationException(nameof(configFile));
|
||||
}
|
||||
|
||||
(BotConfig? botConfig, _) = await BotConfig.Load(configFile, BotName).ConfigureAwait(false);
|
||||
|
||||
if (botConfig == null) {
|
||||
await Destroy().ConfigureAwait(false);
|
||||
|
||||
// Invalid config file, we allow user to fix it without destroying the bot right away
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user