adjust some logging, add reregister button to settings ui, change reconnection to server

This commit is contained in:
Stanley Dimant
2022-07-31 16:56:26 +02:00
parent 4e988984d7
commit aaa68bffd6
3 changed files with 26 additions and 7 deletions

View File

@@ -187,7 +187,7 @@ namespace MareSynchronos.Managers
if (token.IsCancellationRequested) return;
PluginLog.Debug("File changes detected, scanning the changes ");
Logger.Debug("File changes detected");
if (!_modifiedFiles.Any()) return;
@@ -250,7 +250,7 @@ namespace MareSynchronos.Managers
var fileCachesToDelete = new ConcurrentBag<FileCache>();
var fileCachesToAdd = new ConcurrentBag<FileCache>();
Logger.Verbose("Getting file list from Database");
Logger.Debug("Database contains " + fileCaches.Count + " files, local system contains " + TotalFiles);
// scan files from database
Parallel.ForEach(fileCaches, new ParallelOptions()
{
@@ -316,9 +316,12 @@ namespace MareSynchronos.Managers
foreach (var deletion in fileCachesToDelete)
{
var entries = db.FileCaches.Where(f =>
f.Hash == deletion.Hash && f.Filepath == deletion.Filepath);
f.Hash == deletion.Hash && f.Filepath.ToLower() == deletion.Filepath.ToLower());
if (await entries.AnyAsync(ct))
{
Logger.Verbose("Removing file from DB: " + deletion.Filepath);
db.FileCaches.RemoveRange(entries);
}
}
await db.SaveChangesAsync(ct);
foreach (var entry in fileCachesToAdd)

View File

@@ -357,6 +357,24 @@ namespace MareSynchronos.UI
if (_enterSecretKey)
{
ColorTextWrapped("This will overwrite your currently used secret key for the selected service. Make sure to have a backup for the current secret key if you want to switch back to this account.", ImGuiColors.DalamudYellow);
if (!_pluginConfiguration.ClientSecret.ContainsKey(_pluginConfiguration.ApiUri))
{
ColorTextWrapped("IF YOU HAVE NEVER MADE AN ACCOUNT BEFORE DO NOT ENTER ANYTHING HERE", ImGuiColors.DalamudYellow);
}
else
{
ImGui.AlignTextToFramePadding();
ImGui.Text("If you made a mistake before or your account was deleted you can use this to re-register: ");
ImGui.SameLine();
if (ImGui.Button("Register##Reregister"))
{
_pluginConfiguration.FullPause = false;
_pluginConfiguration.Save();
Task.Run(() => _apiController.Register(isIntroUi));
ShowClientSecret = true;
callBackOnExit?.Invoke();
}
}
ImGui.SetNextItemWidth(400);
ImGui.InputText("Enter Secret Key", ref _secretKey, 255);
ImGui.SameLine();

View File

@@ -286,9 +286,7 @@ namespace MareSynchronos.WebAPI
Logger.Info("Connection restored");
await Task.Delay(TimeSpan.FromSeconds(new Random().Next(5, 10)));
_connectionDto = await _mareHub.InvokeAsync<ConnectionDto>(Api.InvokeHeartbeat, _dalamudUtil.PlayerNameHashed, _connectionCancellationTokenSource.Token);
await InitializeData(_connectionCancellationTokenSource.Token);
_ = Task.Run(CreateConnections);
}
private Task MareHubOnReconnecting(Exception? arg)
@@ -305,9 +303,9 @@ namespace MareSynchronos.WebAPI
private async Task StopConnection(CancellationToken token)
{
Logger.Info("Stopping all connections");
if (_mareHub is not null)
{
Logger.Info("Stopping all connections");
await _mareHub.StopAsync(token);
_mareHub.Closed -= MareHubOnClosed;
_mareHub.Reconnected -= MareHubOnReconnected;