Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: safely save for the json files.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Oct 8, 2023
1 parent 5e6d80f commit c7c91e8
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions RotationSolver.Basic/Configuration/OtherConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Dalamud.Game.ClientState.GamePad;
using Dalamud.Logging;
using ECommons.DalamudServices;
using ECommons.DalamudServices;

namespace RotationSolver.Basic.Configuration;

Expand Down Expand Up @@ -190,11 +188,18 @@ private static void Save<T>(T value, string name)

private static void SavePath<T>(T value, string path)
{
File.WriteAllTextAsync(path,
JsonConvert.SerializeObject(value, Formatting.Indented, new JsonSerializerSettings()
try
{
TypeNameHandling = TypeNameHandling.None,
}));
File.WriteAllTextAsync(path,
JsonConvert.SerializeObject(value, Formatting.Indented, new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.None,
}));
}
catch(Exception ex)
{
Svc.Log.Warning(ex, $"Failed to save the file to {path}");
}
}

private static void InitOne<T>(ref T value, string name, bool download = true)
Expand Down Expand Up @@ -239,4 +244,4 @@ private static void InitOne<T>(ref T value, string name, bool download = true)
}
}
}
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

0 comments on commit c7c91e8

Please sign in to comment.