Minor tweaks to Auto-Update process

This commit is contained in:
Brett Hewitson 2022-01-06 12:06:20 +10:00
parent a8edd1052c
commit 8aec461499
2 changed files with 31 additions and 14 deletions

View file

@ -2387,9 +2387,7 @@ namespace ServerManagerTool.Lib
{
try
{
var profile = ServerProfile.LoadFrom(profileFile);
profile.DestroyServerFilesWatcher();
profile.SaveLauncher();
var profile = ServerProfile.LoadFromProfileFileBasic(profileFile, null);
profiles.Add(ServerProfileSnapshot.Create(profile), profile);
}
catch (Exception ex)
@ -2957,7 +2955,8 @@ namespace ServerManagerTool.Lib
ServerProcess = ServerProcess,
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
};
profileExitCodes.TryAdd(profile, app.PerformProfileUpdate(branch, profile));
app.PerformProfileUpdate(branch, profile);
profileExitCodes.TryAdd(profile, app.ExitCode);
});
}
else
@ -2977,7 +2976,8 @@ namespace ServerManagerTool.Lib
ServerProcess = ServerProcess,
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
};
profileExitCodes.TryAdd(profile, app.PerformProfileUpdate(branch, profile));
app.PerformProfileUpdate(branch, profile);
profileExitCodes.TryAdd(profile, app.ExitCode);
}
}
@ -3041,10 +3041,11 @@ namespace ServerManagerTool.Lib
// load all the profiles, do this at the very start in case the user changes one or more while the process is running.
LoadProfiles();
var profiles = _profiles.Keys.Where(p => p.EnableAutoBackup);
var exitCodes = new ConcurrentDictionary<ServerProfileSnapshot, int>();
Parallel.ForEach(_profiles.Keys.Where(p => p.EnableAutoBackup), profile => {
Parallel.ForEach(profiles, profile => {
var app = new ServerApp
{
DeleteOldBackupFiles = Config.Default.AutoBackup_DeleteOldFiles,
@ -3053,7 +3054,8 @@ namespace ServerManagerTool.Lib
SendEmails = true,
ServerProcess = ServerProcessType.AutoBackup
};
exitCodes.TryAdd(profile, app.PerformProfileBackup(profile, CancellationToken.None));
app.PerformProfileBackup(profile, CancellationToken.None);
exitCodes.TryAdd(profile, app.ExitCode);
});
foreach (var profile in _profiles.Keys)