mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Add backup option for failure to load option groups.
This commit is contained in:
parent
18b6b87e6b
commit
ef916fc93c
1 changed files with 7 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using OtterGui.Classes;
|
using OtterGui.Classes;
|
||||||
using OtterGui.Log;
|
using OtterGui.Log;
|
||||||
using Penumbra.Mods;
|
using Penumbra.Mods;
|
||||||
|
using Penumbra.Mods.Subclasses;
|
||||||
|
|
||||||
namespace Penumbra.Services;
|
namespace Penumbra.Services;
|
||||||
|
|
||||||
|
|
@ -18,18 +19,21 @@ public sealed class SaveService : SaveServiceBase<FilenameService>
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <summary> Immediately delete all existing option group files for a mod and save them anew. </summary>
|
/// <summary> Immediately delete all existing option group files for a mod and save them anew. </summary>
|
||||||
public void SaveAllOptionGroups(Mod mod)
|
public void SaveAllOptionGroups(Mod mod, bool backup)
|
||||||
{
|
{
|
||||||
foreach (var file in FileNames.GetOptionGroupFiles(mod))
|
foreach (var file in FileNames.GetOptionGroupFiles(mod))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (file.Exists)
|
if (file.Exists)
|
||||||
file.Delete();
|
if (backup)
|
||||||
|
file.MoveTo(file.FullName + ".bak", true);
|
||||||
|
else
|
||||||
|
file.Delete();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Error($"Could not delete outdated group file {file}:\n{e}");
|
Log.Error($"Could not {(backup ? "move" : "delete")} outdated group file {file}:\n{e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue