Files
NebulaLauncher/Nebula.Shared/Services/ContentService.cs

43 lines
1.6 KiB
C#
Raw Normal View History

2025-07-02 21:32:51 +03:00
using Nebula.Shared.Models;
using Nebula.Shared.Services.Logging;
2025-01-05 17:05:23 +03:00
namespace Nebula.Shared.Services;
[ServiceRegister]
public partial class ContentService(
RestService restService,
DebugService debugService,
ConfigurationService varService,
FileService fileService)
{
private readonly HttpClient _http = new();
private readonly ILogger _logger = debugService.GetLogger("ContentService");
2025-01-05 17:05:23 +03:00
public async Task<RobustBuildInfo> GetBuildInfo(RobustUrl url, CancellationToken cancellationToken)
{
var info = new RobustBuildInfo();
info.Url = url;
var bi = await restService.GetAsync<ServerInfo>(url.InfoUri, cancellationToken);
2025-02-01 18:19:18 +03:00
info.BuildInfo = bi;
2026-01-16 21:02:34 +03:00
if (info.BuildInfo.Build.Acz is null)
{
info.DownloadUri = new RobustZipContentInfo(new Uri(info.BuildInfo.Build.DownloadUrl), info.BuildInfo.Build.Hash);
return info;
}
info.RobustManifestInfo = info.BuildInfo.Build.Acz.Value
2025-01-05 17:05:23 +03:00
? new RobustManifestInfo(new RobustPath(info.Url, "manifest.txt"), new RobustPath(info.Url, "download"),
2025-02-01 18:19:18 +03:00
bi.Build.ManifestHash)
2025-01-05 17:05:23 +03:00
: new RobustManifestInfo(new Uri(info.BuildInfo.Build.ManifestUrl),
2025-02-01 18:19:18 +03:00
new Uri(info.BuildInfo.Build.ManifestDownloadUrl), bi.Build.ManifestHash);
2025-01-05 17:05:23 +03:00
return info;
}
2025-07-02 21:32:51 +03:00
public void RemoveAllContent(ILoadingHandler loadingHandler, CancellationToken cancellationToken)
{
fileService.RemoveAllFiles("content", loadingHandler, cancellationToken);
fileService.RemoveAllFiles("manifest", loadingHandler, cancellationToken);
}
2025-01-05 17:05:23 +03:00
}