prevent secret key input if it's not 40 characters long, check for directory existence in intro ui, check for illegal characters in path
This commit is contained in:
@@ -358,6 +358,7 @@ namespace MareSynchronos.Managers
|
||||
StartWatchers();
|
||||
StartInitialScan();
|
||||
}
|
||||
|
||||
private void StopWatchersAndScan()
|
||||
{
|
||||
_cacheDirWatcher?.Dispose();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<Authors></Authors>
|
||||
<Company></Company>
|
||||
<Version>0.1.12.0</Version>
|
||||
<Version>0.1.13.0</Version>
|
||||
<Description></Description>
|
||||
<Copyright></Copyright>
|
||||
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user