1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-20 00:43:36 +03:00

Move all GuildData to one folder

Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
This commit is contained in:
Macintxsh 2023-09-22 14:22:59 +03:00
parent 1e8b7e5373
commit 4c7b80d458
Signed by: mctaylors
GPG key ID: 361D326747B61E65

View file

@ -73,11 +73,14 @@ public sealed class GuildDataService : IHostedService
private async Task<GuildData> InitializeData(Snowflake guildId, CancellationToken ct = default)
{
var idString = $"{guildId}";
var memberDataPath = $"{guildId}/MemberData";
var settingsPath = $"{guildId}/Settings.json";
var scheduledEventsPath = $"{guildId}/ScheduledEvents.json";
Directory.CreateDirectory(idString);
var path = $"GuildData/{guildId}";
var memberDataPath = $"{path}/MemberData";
var settingsPath = $"{path}/Settings.json";
var scheduledEventsPath = $"{path}/ScheduledEvents.json";
await MigrateGuildData(guildId, path);
Directory.CreateDirectory(path);
if (!File.Exists(settingsPath))
{
@ -127,6 +130,19 @@ public sealed class GuildDataService : IHostedService
return finalData;
}
private static Task MigrateGuildData(Snowflake guildId, string path)
{
var oldPath = $"{guildId}";
if (Directory.Exists(oldPath))
{
Directory.CreateDirectory($"{path}/..");
Directory.Move(oldPath, path);
}
return Task.CompletedTask;
}
public async Task<JsonNode> GetSettings(Snowflake guildId, CancellationToken ct = default)
{
return (await GetData(guildId, ct)).Settings;