Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-load check #200

Merged
merged 2 commits into from
Jul 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
Expand Down Expand Up @@ -378,15 +379,36 @@ public virtual void ApplyGameConfig(bool forceUpdateToLatest = false)
_gameVersionManager.Reinitialize();
}


public virtual bool IsPreloadCompleted()
{
return _gameVersionManager.GetGamePreloadZip().All(x =>
GetLatestPackageList(_assetIndex, GameInstallStateEnum.InstalledHavePreload, true).Wait();
bool resultSlice = false, resultZip=false;
foreach (GameInstallPackage asset in _assetIndex)
{
LogWriteLine(asset.PathOutput);
try
{
resultSlice= asset.Segments != null && asset.Segments.Count != 0 ?
asset.Segments.Select(selector: x => x.GetReadStream(_downloadThreadCount)).ToArray().Length>0 : asset.GetReadStream(_downloadThreadCount).Length>0;
}
catch (Exception ex)
{
LogWriteLine(ex.ToString(), LogType.Default);
continue;
}
}
resultZip = _gameVersionManager.GetGamePreloadZip().All(x =>
{
string name = Path.GetFileName(x.path);
string path = Path.Combine(_gamePath, name);

return File.Exists(path);
});
if (resultZip) LogWriteLine("Zip Found");
if (resultSlice) LogWriteLine("Slices found");
return resultSlice || resultZip;

}

public async Task MoveGameLocation()
Expand Down