From ac80f92f75e9866abce57890898d1a42f15403ff Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Wed, 27 Oct 2021 20:15:02 +0200 Subject: [PATCH] feat: delete dalamudUI.ini over 1.2mb --- .../Interface/Internal/InterfaceManager.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index 150c050e7..6d1df7d5d 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -363,7 +363,24 @@ namespace Dalamud.Interface.Internal var startInfo = Service.Get(); var configuration = Service.Get(); - this.scene.ImGuiIniPath = Path.Combine(Path.GetDirectoryName(startInfo.ConfigurationPath), "dalamudUI.ini"); + var iniFileInfo = new FileInfo(Path.Combine(Path.GetDirectoryName(startInfo.ConfigurationPath), "dalamudUI.ini")); + + try + { + if (iniFileInfo.Length > 1200000) + { + Log.Warning("dalamudUI.ini was over 1mb, deleting"); + iniFileInfo.CopyTo(Path.Combine(iniFileInfo.DirectoryName, + $"dalamudUI-{DateTimeOffset.Now.ToUnixTimeSeconds()}.ini")); + iniFileInfo.Delete(); + } + } + catch (Exception ex) + { + Log.Error(ex, "Could not delete dalamudUI.ini"); + } + + this.scene.ImGuiIniPath = iniFileInfo.FullName; this.scene.OnBuildUI += this.Display; this.scene.OnNewInputFrame += this.OnNewInputFrame;