mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Better backup
This commit is contained in:
parent
bca0e2ffed
commit
313267427b
@ -227,6 +227,24 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
|
||||
var json = loadedConfigFiles[filePath].ToSerializedJson();
|
||||
|
||||
try
|
||||
{
|
||||
var path = loadedMod.ModHelper.Manifest.ModFolderPath + backupFolderName + relativePath;
|
||||
Logger.LogVerbose($"Backing up... {relativePath} to {path}");
|
||||
var oldPath = loadedMod.ModHelper.Manifest.ModFolderPath + relativePath;
|
||||
var directoryName = Path.GetDirectoryName(path);
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
if (File.Exists(oldPath))
|
||||
File.WriteAllBytes(path, File.ReadAllBytes(oldPath));
|
||||
else
|
||||
File.WriteAllText(path, json);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Failed to save backup file {backupFolderName}{relativePath}:\n{e}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Logger.Log($"Saving... {relativePath} to {filePath}");
|
||||
@ -240,19 +258,6 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
{
|
||||
Logger.LogError($"Failed to save file {relativePath}:\n{e}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var path = Main.Instance.ModHelper.Manifest.ModFolderPath + backupFolderName + relativePath;
|
||||
var directoryName = Path.GetDirectoryName(path);
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
File.WriteAllText(path, json);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Failed to save backup file {backupFolderName}{relativePath}:\n{e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user