Skip to content

Commit

Permalink
store repo state in json, instead of toml
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Oct 5, 2024
1 parent 06e0627 commit 13a84fa
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Plogon/Repo/PluginRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;

using Serilog;

using Tomlyn;

namespace Plogon.Repo;

/// <summary>
Expand All @@ -15,7 +14,7 @@ namespace Plogon.Repo;
public class PluginRepository
{
private readonly DirectoryInfo repoDirectory;
private FileInfo StateFile => new FileInfo(Path.Combine(repoDirectory.FullName, "State.toml"));
private FileInfo StateFile => new FileInfo(Path.Combine(repoDirectory.FullName, "state.json"));

/// <summary>
/// Current state of the repository
Expand All @@ -32,7 +31,8 @@ public PluginRepository(DirectoryInfo repoDirectory)

if (StateFile.Exists)
{
this.State = Toml.ToModel<State>(StateFile.OpenText().ReadToEnd());
this.State = JsonSerializer.Deserialize<State>(StateFile.OpenText().ReadToEnd())
?? throw new Exception("Failed to load state");
}
else
{
Expand All @@ -43,7 +43,10 @@ public PluginRepository(DirectoryInfo repoDirectory)

private void SaveState()
{
File.WriteAllText(this.StateFile.FullName, Toml.FromModel(this.State));
File.WriteAllText(this.StateFile.FullName, JsonSerializer.Serialize(this.State, new JsonSerializerOptions
{
WriteIndented = true,
}));
}

/// <summary>
Expand Down

0 comments on commit 13a84fa

Please sign in to comment.