change namings, port, fix clearing uploads

This commit is contained in:
Stanley Dimant
2022-07-01 11:29:19 +02:00
parent 320b80e3ae
commit 35b12720c6
4 changed files with 38 additions and 8 deletions

View File

@@ -114,6 +114,35 @@ namespace MareSynchronos
UidComments.Clear(); UidComments.Clear();
Save(); Save();
} }
if (Version == 1)
{
Logger.Debug("Migrating Configuration from V1 to V2");
ApiUri = ApiUri.Replace("5001", "5000");
foreach (var kvp in ClientSecret.ToList())
{
var newKey = kvp.Key.Replace("5001", "5000");
ClientSecret.Remove(kvp.Key);
if (ClientSecret.ContainsKey(newKey))
{
ClientSecret[newKey] = kvp.Value;
}
else
{
ClientSecret.Add(newKey, kvp.Value);
}
}
foreach (var kvp in UidServerComments.ToList())
{
var newKey = kvp.Key.Replace("5001", "5000");
UidServerComments.Remove(kvp.Key);
UidServerComments.Add(newKey, kvp.Value);
}
Version = 2;
Save();
}
} }
} }
} }

View File

@@ -82,7 +82,7 @@ namespace MareSynchronos.UI
} }
else else
{ {
string error = _configuration.FullPause ? "Fully Paused" : _apiController.ServerAlive ? "Unauthorized" : "Service unavailable"; string error = _configuration.FullPause ? "Disconnected" : _apiController.ServerAlive ? "Unauthorized" : "Service unavailable";
ImGui.TextColored(ImGuiColors.DalamudRed, $"No UID ({error})"); ImGui.TextColored(ImGuiColors.DalamudRed, $"No UID ({error})");
ImGui.SetWindowFontScale(1.0f); ImGui.SetWindowFontScale(1.0f);
if (_apiController.ServerAlive && !_configuration.FullPause) if (_apiController.ServerAlive && !_configuration.FullPause)
@@ -454,7 +454,7 @@ namespace MareSynchronos.UI
if (!_configuration.FullPause) if (!_configuration.FullPause)
{ {
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
UiShared.TextWrapped("Note: to change servers you need to pause Mare Synchronos."); UiShared.TextWrapped("Note: to change servers you need to disconnect from your current Mare Synchronos server.");
ImGui.PopStyleColor(); ImGui.PopStyleColor();
} }
@@ -462,19 +462,19 @@ namespace MareSynchronos.UI
if (_configuration.HasValidSetup()) if (_configuration.HasValidSetup())
{ {
if (ImGui.Checkbox("Pause Mare Synchronos", ref marePaused)) if (ImGui.Checkbox("Disconnect Mare Synchronos", ref marePaused))
{ {
_configuration.FullPause = marePaused; _configuration.FullPause = marePaused;
_configuration.Save(); _configuration.Save();
Task.Run(_apiController.CreateConnections); Task.Run(_apiController.CreateConnections);
} }
UiShared.DrawHelpText("Completely pauses the sync and clear your current data (not uploaded files) on the service."); UiShared.DrawHelpText("Completely pauses the sync and clears your current data (not uploaded files) on the service.");
} }
else else
{ {
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
ImGui.TextUnformatted("You cannot resume pause without a valid account on the service."); ImGui.TextUnformatted("You cannot reconnect without a valid account on the service.");
ImGui.PopStyleColor(); ImGui.PopStyleColor();
} }

View File

@@ -24,7 +24,8 @@ namespace MareSynchronos.WebAPI
{ {
Logger.Warn("Cancelling upload"); Logger.Warn("Cancelling upload");
_uploadCancellationTokenSource?.Cancel(); _uploadCancellationTokenSource?.Cancel();
_fileHub!.InvokeAsync("AbortUpload"); _fileHub!.SendAsync("AbortUpload");
CurrentUploads.Clear();
} }
} }
@@ -167,7 +168,7 @@ namespace MareSynchronos.WebAPI
Logger.Verbose("Compressing and uploading " + file); Logger.Verbose("Compressing and uploading " + file);
var data = await GetCompressedFileData(file.Hash, uploadToken); var data = await GetCompressedFileData(file.Hash, uploadToken);
CurrentUploads.Single(e => e.Hash == data.Item1).Total = data.Item2.Length; CurrentUploads.Single(e => e.Hash == data.Item1).Total = data.Item2.Length;
_ = UploadFile(data.Item2, file.Hash, uploadToken); await UploadFile(data.Item2, file.Hash, uploadToken);
if (!uploadToken.IsCancellationRequested) continue; if (!uploadToken.IsCancellationRequested) continue;
Logger.Warn("Cancel in filesToUpload loop detected"); Logger.Warn("Cancel in filesToUpload loop detected");
CurrentUploads.Clear(); CurrentUploads.Clear();

View File

@@ -17,7 +17,7 @@ namespace MareSynchronos.WebAPI
{ {
#if DEBUG #if DEBUG
public const string MainServer = "darkarchons Debug Server (Dev Server (CH))"; public const string MainServer = "darkarchons Debug Server (Dev Server (CH))";
public const string MainServiceUri = "wss://darkarchon.internet-box.ch:5001"; public const string MainServiceUri = "wss://darkarchon.internet-box.ch:5000";
#else #else
public const string MainServer = "Lunae Crescere Incipientis (Central Server EU)"; public const string MainServer = "Lunae Crescere Incipientis (Central Server EU)";
public const string MainServiceUri = "to be defined"; public const string MainServiceUri = "to be defined";