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:
parent
1e8b7e5373
commit
4c7b80d458
1 changed files with 21 additions and 5 deletions
|
@ -73,11 +73,14 @@ public sealed class GuildDataService : IHostedService
|
||||||
|
|
||||||
private async Task<GuildData> InitializeData(Snowflake guildId, CancellationToken ct = default)
|
private async Task<GuildData> InitializeData(Snowflake guildId, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
var idString = $"{guildId}";
|
var path = $"GuildData/{guildId}";
|
||||||
var memberDataPath = $"{guildId}/MemberData";
|
var memberDataPath = $"{path}/MemberData";
|
||||||
var settingsPath = $"{guildId}/Settings.json";
|
var settingsPath = $"{path}/Settings.json";
|
||||||
var scheduledEventsPath = $"{guildId}/ScheduledEvents.json";
|
var scheduledEventsPath = $"{path}/ScheduledEvents.json";
|
||||||
Directory.CreateDirectory(idString);
|
|
||||||
|
await MigrateGuildData(guildId, path);
|
||||||
|
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
|
||||||
if (!File.Exists(settingsPath))
|
if (!File.Exists(settingsPath))
|
||||||
{
|
{
|
||||||
|
@ -127,6 +130,19 @@ public sealed class GuildDataService : IHostedService
|
||||||
return finalData;
|
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)
|
public async Task<JsonNode> GetSettings(Snowflake guildId, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
return (await GetData(guildId, ct)).Settings;
|
return (await GetData(guildId, ct)).Settings;
|
||||||
|
|
Loading…
Add table
Reference in a new issue