fix: save config + manifests by first writing them to another file and moving them over

Should hopefully make corrupted configs a bit more rare
This commit is contained in:
goat 2023-03-19 13:11:27 +01:00
parent 111eea290c
commit 86181cd2d4
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
4 changed files with 22 additions and 6 deletions

View file

@ -68,7 +68,7 @@ internal record LocalPluginManifest : PluginManifest
/// Save a plugin manifest to file.
/// </summary>
/// <param name="manifestFile">Path to save at.</param>
public void Save(FileInfo manifestFile) => File.WriteAllText(manifestFile.FullName, JsonConvert.SerializeObject(this, Formatting.Indented));
public void Save(FileInfo manifestFile) => Util.WriteAllTextSafe(manifestFile.FullName, JsonConvert.SerializeObject(this, Formatting.Indented));
/// <summary>
/// Loads a plugin manifest from file.