potentially fix mac, fix cancel downloads
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Dalamud.Logging;
|
||||||
|
using MareSynchronos.Utils;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
@@ -24,7 +26,18 @@ namespace MareSynchronos.FileCacheDB
|
|||||||
{
|
{
|
||||||
if (!optionsBuilder.IsConfigured)
|
if (!optionsBuilder.IsConfigured)
|
||||||
{
|
{
|
||||||
string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "pluginConfigs", "FileCacheDebug.db");
|
string dbPath = Path.Combine(Plugin.PluginInterface.ConfigDirectory.FullName, "FileCacheDebug.db");
|
||||||
|
if(!Directory.Exists(Plugin.PluginInterface.ConfigDirectory.FullName))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Plugin.PluginInterface.ConfigDirectory.FullName);
|
||||||
|
}
|
||||||
|
var oldDbPath = Path.Combine(Plugin.PluginInterface.ConfigDirectory.FullName, "..", "FileCacheDebug.db");
|
||||||
|
if (File.Exists(oldDbPath))
|
||||||
|
{
|
||||||
|
Logger.Debug("Migrated old path to new path");
|
||||||
|
File.Move(oldDbPath, dbPath, true);
|
||||||
|
}
|
||||||
|
//PluginLog.Debug("Using Database " + dbPath);
|
||||||
optionsBuilder.UseSqlite("Data Source=" + dbPath);
|
optionsBuilder.UseSqlite("Data Source=" + dbPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class CachedPlayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CancellationTokenSource _downloadCancellationTokenSource = new();
|
private CancellationTokenSource? _downloadCancellationTokenSource;
|
||||||
|
|
||||||
private string _lastGlamourerData = string.Empty;
|
private string _lastGlamourerData = string.Empty;
|
||||||
|
|
||||||
@@ -93,9 +93,12 @@ public class CachedPlayer
|
|||||||
await _apiController.DownloadFiles(toDownloadReplacements, downloadToken);
|
await _apiController.DownloadFiles(toDownloadReplacements, downloadToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_downloadCancellationTokenSource.Token.IsCancellationRequested)
|
if (downloadToken.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ApplyCharacterData(e.CharacterData, moddedPaths);
|
ApplyCharacterData(e.CharacterData, moddedPaths);
|
||||||
}, downloadToken);
|
}, downloadToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +155,7 @@ public class CachedPlayer
|
|||||||
{
|
{
|
||||||
Logger.Debug("Restoring state for " + PlayerName);
|
Logger.Debug("Restoring state for " + PlayerName);
|
||||||
IsVisible = false;
|
IsVisible = false;
|
||||||
|
_downloadCancellationTokenSource?.Dispose();
|
||||||
_watcher.RemovePlayerFromWatch(PlayerName);
|
_watcher.RemovePlayerFromWatch(PlayerName);
|
||||||
_ipcManager.PenumbraRemoveTemporaryCollection(PlayerName);
|
_ipcManager.PenumbraRemoveTemporaryCollection(PlayerName);
|
||||||
_ipcManager.GlamourerRevertCharacterCustomization(PlayerName);
|
_ipcManager.GlamourerRevertCharacterCustomization(PlayerName);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace MareSynchronos
|
|||||||
private readonly IntroUi _introUi;
|
private readonly IntroUi _introUi;
|
||||||
private readonly IpcManager _ipcManager;
|
private readonly IpcManager _ipcManager;
|
||||||
private readonly ObjectTable _objectTable;
|
private readonly ObjectTable _objectTable;
|
||||||
private readonly DalamudPluginInterface _pluginInterface;
|
public static DalamudPluginInterface PluginInterface { get; set; }
|
||||||
private readonly PluginUi _pluginUi;
|
private readonly PluginUi _pluginUi;
|
||||||
private readonly WindowSystem _windowSystem;
|
private readonly WindowSystem _windowSystem;
|
||||||
private PlayerManager? _characterManager;
|
private PlayerManager? _characterManager;
|
||||||
@@ -41,13 +41,13 @@ namespace MareSynchronos
|
|||||||
Framework framework, ObjectTable objectTable, ClientState clientState)
|
Framework framework, ObjectTable objectTable, ClientState clientState)
|
||||||
{
|
{
|
||||||
Logger.Debug("Launching " + Name);
|
Logger.Debug("Launching " + Name);
|
||||||
_pluginInterface = pluginInterface;
|
PluginInterface = pluginInterface;
|
||||||
_commandManager = commandManager;
|
_commandManager = commandManager;
|
||||||
_framework = framework;
|
_framework = framework;
|
||||||
_objectTable = objectTable;
|
_objectTable = objectTable;
|
||||||
_clientState = clientState;
|
_clientState = clientState;
|
||||||
_configuration = _pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
_configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||||
_configuration.Initialize(_pluginInterface);
|
_configuration.Initialize(PluginInterface);
|
||||||
|
|
||||||
_windowSystem = new WindowSystem("MareSynchronos");
|
_windowSystem = new WindowSystem("MareSynchronos");
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ namespace MareSynchronos
|
|||||||
|
|
||||||
// those can be initialized outside of game login
|
// those can be initialized outside of game login
|
||||||
_apiController = new ApiController(_configuration);
|
_apiController = new ApiController(_configuration);
|
||||||
_ipcManager = new IpcManager(_pluginInterface);
|
_ipcManager = new IpcManager(PluginInterface);
|
||||||
|
|
||||||
_fileCacheManager = new FileCacheManager(_ipcManager, _configuration);
|
_fileCacheManager = new FileCacheManager(_ipcManager, _configuration);
|
||||||
|
|
||||||
@@ -121,8 +121,8 @@ namespace MareSynchronos
|
|||||||
{
|
{
|
||||||
Logger.Debug("Client login");
|
Logger.Debug("Client login");
|
||||||
|
|
||||||
_pluginInterface.UiBuilder.Draw += Draw;
|
PluginInterface.UiBuilder.Draw += Draw;
|
||||||
_pluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;
|
PluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;
|
||||||
_commandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
|
_commandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
|
||||||
{
|
{
|
||||||
HelpMessage = "Opens the Mare Synchronos UI"
|
HelpMessage = "Opens the Mare Synchronos UI"
|
||||||
@@ -142,8 +142,8 @@ namespace MareSynchronos
|
|||||||
Logger.Debug("Client logout");
|
Logger.Debug("Client logout");
|
||||||
_characterCacheManager?.Dispose();
|
_characterCacheManager?.Dispose();
|
||||||
_characterManager?.Dispose();
|
_characterManager?.Dispose();
|
||||||
_pluginInterface.UiBuilder.Draw -= Draw;
|
PluginInterface.UiBuilder.Draw -= Draw;
|
||||||
_pluginInterface.UiBuilder.OpenConfigUi -= OpenConfigUi;
|
PluginInterface.UiBuilder.OpenConfigUi -= OpenConfigUi;
|
||||||
_commandManager.RemoveHandler(CommandName);
|
_commandManager.RemoveHandler(CommandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user