diff --git a/MareSynchronos/Managers/FileCacheManager.cs b/MareSynchronos/Managers/FileCacheManager.cs index 3e20fe5..bb625b8 100644 --- a/MareSynchronos/Managers/FileCacheManager.cs +++ b/MareSynchronos/Managers/FileCacheManager.cs @@ -358,6 +358,7 @@ namespace MareSynchronos.Managers StartWatchers(); StartInitialScan(); } + private void StopWatchersAndScan() { _cacheDirWatcher?.Dispose(); diff --git a/MareSynchronos/MareSynchronos.csproj b/MareSynchronos/MareSynchronos.csproj index d972d1f..53f4a1c 100644 --- a/MareSynchronos/MareSynchronos.csproj +++ b/MareSynchronos/MareSynchronos.csproj @@ -3,7 +3,7 @@ - 0.1.12.0 + 0.1.13.0 https://github.com/Penumbra-Sync/client diff --git a/MareSynchronos/UI/IntroUI.cs b/MareSynchronos/UI/IntroUI.cs index 1bdb250..ccf657c 100644 --- a/MareSynchronos/UI/IntroUI.cs +++ b/MareSynchronos/UI/IntroUI.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Numerics; using Dalamud.Interface.Colors; using Dalamud.Interface.Windowing; @@ -105,7 +106,10 @@ namespace MareSynchronos.UI } } } - else if (_pluginConfiguration.AcceptedAgreement && (string.IsNullOrEmpty(_pluginConfiguration.CacheFolder) || _pluginConfiguration.InitialScanComplete == false)) + else if (_pluginConfiguration.AcceptedAgreement + && (string.IsNullOrEmpty(_pluginConfiguration.CacheFolder) + || _pluginConfiguration.InitialScanComplete == false + || !Directory.Exists(_pluginConfiguration.CacheFolder))) { if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont); ImGui.TextUnformatted("File Cache Setup"); diff --git a/MareSynchronos/UI/UIShared.cs b/MareSynchronos/UI/UIShared.cs index 7a712c0..7060641 100644 --- a/MareSynchronos/UI/UIShared.cs +++ b/MareSynchronos/UI/UIShared.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Numerics; using System.Runtime.InteropServices; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Dalamud.Interface; using Dalamud.Interface.Colors; @@ -247,6 +248,7 @@ namespace MareSynchronos.UI private string _customServerUri = ""; private bool _enterSecretKey = false; private bool _cacheDirectoryHasOtherFilesThanCache = false; + private bool _cacheDirectoryHasIllegalCharacter = false; public void DrawServiceSelection(Action? callBackOnExit = null, bool isIntroUi = false) { @@ -349,15 +351,23 @@ namespace MareSynchronos.UI ImGui.SetNextItemWidth(400); ImGui.InputText("Enter Secret Key", ref _secretKey, 255); ImGui.SameLine(); - if (ImGui.Button("Save")) + if (_secretKey.Length > 0 && _secretKey.Length != 40) { - _pluginConfiguration.ClientSecret[_pluginConfiguration.ApiUri] = _secretKey; - _pluginConfiguration.Save(); - _secretKey = string.Empty; - Task.Run(_apiController.CreateConnections); - ShowClientSecret = false; - _enterSecretKey = false; - callBackOnExit?.Invoke(); + ColorTextWrapped("Your secret key must be exactly 40 characters long. If try to enter your UID here, this is incorrect." + + " If you have lost your secret key, you will need to create a new account.", ImGuiColors.DalamudRed); + } + else + { + if (ImGui.Button("Save")) + { + _pluginConfiguration.ClientSecret[_pluginConfiguration.ApiUri] = _secretKey; + _pluginConfiguration.Save(); + _secretKey = string.Empty; + Task.Run(_apiController.CreateConnections); + ShowClientSecret = false; + _enterSecretKey = false; + callBackOnExit?.Invoke(); + } } } } @@ -400,12 +410,14 @@ namespace MareSynchronos.UI _isPenumbraDirectory = path.ToLower() == _ipcManager.PenumbraModDirectory()?.ToLower(); _isDirectoryWritable = IsDirectoryWritable(path); _cacheDirectoryHasOtherFilesThanCache = Directory.GetFiles(path, "*", SearchOption.AllDirectories).Any(f => new FileInfo(f).Name.Length != 40); + _cacheDirectoryHasIllegalCharacter = Regex.IsMatch(path, @"^(\w:\\(\w|\\)*|\/(\w|\/)*)"); if (!string.IsNullOrEmpty(path) && Directory.Exists(path) && _isDirectoryWritable && !_isPenumbraDirectory - && !_cacheDirectoryHasOtherFilesThanCache) + && !_cacheDirectoryHasOtherFilesThanCache + && !_cacheDirectoryHasIllegalCharacter) { _pluginConfiguration.CacheFolder = path; _pluginConfiguration.Save(); @@ -426,6 +438,10 @@ namespace MareSynchronos.UI else if (_cacheDirectoryHasOtherFilesThanCache) { ColorTextWrapped("Your selected directory has files inside that are not Mare related. Use an empty directory or a previous Mare cache directory only.", ImGuiColors.DalamudRed); + } else if (_cacheDirectoryHasIllegalCharacter) + { + ColorTextWrapped("Your selected directory contains illegal characters unreadable by FFXIV. " + + "Restrict yourself to latin letters (A-Z), underscores (_) and arabic numbers (0-9).", ImGuiColors.DalamudRed); } int maxCacheSize = _pluginConfiguration.MaxLocalCacheInGiB;