mirror of
https://github.com/tribufu/ServerManagers
synced 2026-06-01 09:42:39 +00:00
Minor tweaks to Auto-Update process
This commit is contained in:
parent
a8edd1052c
commit
8aec461499
2 changed files with 31 additions and 14 deletions
|
|
@ -2387,9 +2387,7 @@ namespace ServerManagerTool.Lib
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var profile = ServerProfile.LoadFrom(profileFile);
|
var profile = ServerProfile.LoadFromProfileFileBasic(profileFile, null);
|
||||||
profile.DestroyServerFilesWatcher();
|
|
||||||
profile.SaveLauncher();
|
|
||||||
profiles.Add(ServerProfileSnapshot.Create(profile), profile);
|
profiles.Add(ServerProfileSnapshot.Create(profile), profile);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -2957,7 +2955,8 @@ namespace ServerManagerTool.Lib
|
||||||
ServerProcess = ServerProcess,
|
ServerProcess = ServerProcess,
|
||||||
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
|
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
|
||||||
};
|
};
|
||||||
profileExitCodes.TryAdd(profile, app.PerformProfileUpdate(branch, profile));
|
app.PerformProfileUpdate(branch, profile);
|
||||||
|
profileExitCodes.TryAdd(profile, app.ExitCode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -2977,7 +2976,8 @@ namespace ServerManagerTool.Lib
|
||||||
ServerProcess = ServerProcess,
|
ServerProcess = ServerProcess,
|
||||||
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
|
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.
|
// load all the profiles, do this at the very start in case the user changes one or more while the process is running.
|
||||||
LoadProfiles();
|
LoadProfiles();
|
||||||
|
|
||||||
|
var profiles = _profiles.Keys.Where(p => p.EnableAutoBackup);
|
||||||
var exitCodes = new ConcurrentDictionary<ServerProfileSnapshot, int>();
|
var exitCodes = new ConcurrentDictionary<ServerProfileSnapshot, int>();
|
||||||
|
|
||||||
Parallel.ForEach(_profiles.Keys.Where(p => p.EnableAutoBackup), profile => {
|
Parallel.ForEach(profiles, profile => {
|
||||||
var app = new ServerApp
|
var app = new ServerApp
|
||||||
{
|
{
|
||||||
DeleteOldBackupFiles = Config.Default.AutoBackup_DeleteOldFiles,
|
DeleteOldBackupFiles = Config.Default.AutoBackup_DeleteOldFiles,
|
||||||
|
|
@ -3053,7 +3054,8 @@ namespace ServerManagerTool.Lib
|
||||||
SendEmails = true,
|
SendEmails = true,
|
||||||
ServerProcess = ServerProcessType.AutoBackup
|
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)
|
foreach (var profile in _profiles.Keys)
|
||||||
|
|
|
||||||
|
|
@ -908,6 +908,22 @@ namespace ServerManagerTool.Lib
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ServerProfile LoadFromProfileFile(string file, ServerProfile profile)
|
public static ServerProfile LoadFromProfileFile(string file, ServerProfile profile)
|
||||||
|
{
|
||||||
|
profile = LoadFromProfileFileBasic(file, profile);
|
||||||
|
|
||||||
|
if (profile is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
profile.CheckLauncherArgs();
|
||||||
|
|
||||||
|
profile.LoadServerFiles(true, true);
|
||||||
|
profile.SetupServerFilesWatcher();
|
||||||
|
|
||||||
|
profile._lastSaveLocation = file;
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ServerProfile LoadFromProfileFileBasic(string file, ServerProfile profile)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
|
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -945,17 +961,12 @@ namespace ServerManagerTool.Lib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.CheckLauncherArgs();
|
|
||||||
|
|
||||||
var serverConfigFile = Path.Combine(GetProfileServerConfigDir(profile), Config.Default.ServerGameConfigFile);
|
var serverConfigFile = Path.Combine(GetProfileServerConfigDir(profile), Config.Default.ServerGameConfigFile);
|
||||||
if (File.Exists(serverConfigFile))
|
if (File.Exists(serverConfigFile))
|
||||||
{
|
{
|
||||||
profile = LoadFromConfigFiles(serverConfigFile, profile);
|
profile = LoadFromConfigFiles(serverConfigFile, profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.LoadServerFiles(true, true);
|
|
||||||
profile.SetupServerFilesWatcher();
|
|
||||||
|
|
||||||
profile._lastSaveLocation = file;
|
profile._lastSaveLocation = file;
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
@ -1047,10 +1058,14 @@ namespace ServerManagerTool.Lib
|
||||||
|
|
||||||
public void SaveProfile()
|
public void SaveProfile()
|
||||||
{
|
{
|
||||||
|
var settings = new JsonSerializerSettings();
|
||||||
|
settings.Converters.Add(new NullableValueConverter<int>());
|
||||||
|
settings.Converters.Add(new NullableValueConverter<float>());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save the profile
|
// Save the profile
|
||||||
//
|
//
|
||||||
JsonUtils.SerializeToFile(this, GetProfileFile());
|
JsonUtils.SerializeToFile(this, GetProfileFile(), settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveLauncher()
|
public void SaveLauncher()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue