mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix predownload latest path and name
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
internal static class LatestPackageExtension
|
||||
{
|
||||
public static void Patch(this LatestPackage latest)
|
||||
{
|
||||
StringBuilder pathBuilder = new();
|
||||
foreach (PackageSegment segment in latest.Segments)
|
||||
{
|
||||
pathBuilder.AppendLine(segment.Path);
|
||||
}
|
||||
|
||||
latest.Path = pathBuilder.ToStringTrimEndReturn();
|
||||
latest.Name = latest.Segments[0].Path[..^4]; // .00X
|
||||
}
|
||||
}
|
||||
@@ -46,18 +46,16 @@ internal sealed partial class ResourceClient
|
||||
.TryCatchSendAsync<Response<GameResource>>(httpClient, logger, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
// 补全缺失的信息
|
||||
// 最新版完整包
|
||||
if (resp is { Data.Game.Latest: LatestPackage latest })
|
||||
{
|
||||
StringBuilder pathBuilder = new();
|
||||
foreach (PackageSegment segment in latest.Segments)
|
||||
{
|
||||
pathBuilder.AppendLine(segment.Path);
|
||||
}
|
||||
latest.Patch();
|
||||
}
|
||||
|
||||
latest.Path = pathBuilder.ToStringTrimEndReturn();
|
||||
string path = latest.Segments[0].Path[..^4]; // .00X
|
||||
latest.Name = Path.GetFileName(path);
|
||||
// 预下载完整包
|
||||
if (resp is { Data.PreDownloadGame.Latest: LatestPackage preDownloadLatest })
|
||||
{
|
||||
preDownloadLatest.Patch();
|
||||
}
|
||||
|
||||
return Response.Response.DefaultIfNull(resp);
|
||||
|
||||
Reference in New Issue
Block a user