Ensure that the bias workspace is present

This commit is contained in:
Thorsten Sommer 2024-10-26 22:16:17 +02:00
parent 0b367a4542
commit 893be39935
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -37,6 +37,7 @@ public partial class Workspaces : ComponentBase
private const Placement WORKSPACE_ITEM_TOOLTIP_PLACEMENT = Placement.Bottom;
private static readonly Guid WORKSPACE_ID_BIAS = Guid.Parse("82050a4e-ee92-43d7-8ee5-ab512f847e02");
private static readonly JsonSerializerOptions JSON_OPTIONS = new()
{
WriteIndented = true,
@ -64,6 +65,7 @@ public partial class Workspaces : ComponentBase
//
await this.LoadTreeItems();
await this.EnsureBiasWorkspace();
await base.OnInitializedAsync();
}
@ -434,6 +436,19 @@ public partial class Workspaces : ComponentBase
await this.LoadTreeItems();
}
private async Task EnsureBiasWorkspace()
{
var workspacePath = Path.Join(SettingsManager.DataDirectory, "workspaces", WORKSPACE_ID_BIAS.ToString());
if(Path.Exists(workspacePath))
return;
Directory.CreateDirectory(workspacePath);
var workspaceNamePath = Path.Join(workspacePath, "name");
await File.WriteAllTextAsync(workspaceNamePath, "Bias of the Day", Encoding.UTF8);
await this.LoadTreeItems();
}
private async Task DeleteWorkspace(string? workspacePath)
{