mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using System.Text.Json;
|
|
using LanMountainDesktop.Launcher.Models;
|
|
|
|
namespace LanMountainDesktop.Launcher.Update;
|
|
|
|
internal sealed class InstallCheckpointStore(UpdateEnginePaths paths)
|
|
{
|
|
public InstallCheckpoint? Load()
|
|
{
|
|
if (!File.Exists(paths.InstallCheckpointPath))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
try
|
|
{
|
|
var text = File.ReadAllText(paths.InstallCheckpointPath);
|
|
if (string.IsNullOrWhiteSpace(text))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return JsonSerializer.Deserialize(text, AppJsonContext.Default.InstallCheckpoint);
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public void Save(InstallCheckpoint checkpoint)
|
|
{
|
|
File.WriteAllText(paths.InstallCheckpointPath, JsonSerializer.Serialize(checkpoint, AppJsonContext.Default.InstallCheckpoint));
|
|
}
|
|
|
|
public void Delete()
|
|
{
|
|
try
|
|
{
|
|
if (File.Exists(paths.InstallCheckpointPath))
|
|
{
|
|
File.Delete(paths.InstallCheckpointPath);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
}
|