fix package converter missing directory

This commit is contained in:
Lightczx
2023-07-30 21:51:16 +08:00
parent d3b72ecb98
commit a661530025
4 changed files with 9 additions and 6 deletions

View File

@@ -6,7 +6,6 @@ using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
using Snap.Hutao.Core.ExceptionService;
using Snap.Hutao.Core.IO;
using Snap.Hutao.Core.IO.Hashing;
using Snap.Hutao.Service.Notification;
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
using System.IO;
using System.IO.Compression;
@@ -260,6 +259,7 @@ internal sealed partial class PackageConverter
}
// Cache no matching item, download
Directory.CreateDirectory(context.ServerCacheTargetFolder);
using (FileStream fileStream = File.Create(cacheFile))
{
string remoteUrl = context.GetScatteredFilesUrl(remoteName);

View File

@@ -29,9 +29,12 @@ internal sealed class PackageReplaceStatus : ICloneable<PackageReplaceStatus>
public PackageReplaceStatus(string name, long bytesRead, long totalBytes)
{
Percent = (double)bytesRead / totalBytes;
Description = $"{name}\n{Converters.ToFileSizeString(bytesRead)}/{Converters.ToFileSizeString(totalBytes)}";
Name = name;
Description = $"{Converters.ToFileSizeString(bytesRead)}/{Converters.ToFileSizeString(totalBytes)}";
}
public string Name { get; set; }
/// <summary>
/// 描述
/// </summary>

View File

@@ -40,7 +40,7 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
}
/// <inheritdoc/>
public async Task UnlockAsync(UnlockTimingOptions options, IProgress<UnlockerStatus> progress, CancellationToken token = default)
public async ValueTask UnlockAsync(UnlockTimingOptions options, IProgress<UnlockerStatus> progress, CancellationToken token = default)
{
Verify.Operation(status.IsUnlockerValid, "This Unlocker is invalid");
@@ -177,7 +177,7 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
return FindModuleResult.ModuleNotLoaded;
}
private async Task<ValueResult<FindModuleResult, GameModule>> FindModuleAsync(TimeSpan findModuleDelay, TimeSpan findModuleLimit)
private async ValueTask<ValueResult<FindModuleResult, GameModule>> FindModuleAsync(TimeSpan findModuleDelay, TimeSpan findModuleLimit)
{
ValueStopwatch watch = ValueStopwatch.StartNew();
using (PeriodicTimer timer = new(findModuleDelay))
@@ -205,7 +205,7 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
return new(FindModuleResult.TimeLimitExeeded, default);
}
private async Task LoopAdjustFpsAsync(TimeSpan adjustFpsDelay, IProgress<UnlockerStatus> progress, CancellationToken token)
private async ValueTask LoopAdjustFpsAsync(TimeSpan adjustFpsDelay, IProgress<UnlockerStatus> progress, CancellationToken token)
{
using (PeriodicTimer timer = new(adjustFpsDelay))
{

View File

@@ -16,5 +16,5 @@ internal interface IGameFpsUnlocker
/// <param name="progress">进度</param>
/// <param name="token">取消令牌</param>
/// <returns>解锁的结果</returns>
Task UnlockAsync(UnlockTimingOptions options, IProgress<UnlockerStatus> progress, CancellationToken token = default);
ValueTask UnlockAsync(UnlockTimingOptions options, IProgress<UnlockerStatus> progress, CancellationToken token = default);
}