mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-18 16:41:36 -07:00
Only extract files when necessary
This commit is contained in:
parent
67f673ae85
commit
e318c98c41
@ -60,6 +60,7 @@ namespace Bloxstrap
|
||||
|
||||
private string _latestVersionGuid = null!;
|
||||
private PackageManifest _versionPackageManifest = null!;
|
||||
private FileManifest _versionFileManifest = null!;
|
||||
private string _versionFolder = null!;
|
||||
|
||||
private bool _isInstalling = false;
|
||||
@ -262,6 +263,7 @@ namespace Bloxstrap
|
||||
_latestVersionGuid = clientVersion.VersionGuid;
|
||||
_versionFolder = Path.Combine(Paths.Versions, _latestVersionGuid);
|
||||
_versionPackageManifest = await PackageManifest.Get(_latestVersionGuid);
|
||||
_versionFileManifest = await FileManifest.Get(_latestVersionGuid);
|
||||
}
|
||||
|
||||
private async Task StartRoblox()
|
||||
@ -1402,6 +1404,16 @@ namespace Bloxstrap
|
||||
if (directory is not null)
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
if (File.Exists(extractPath))
|
||||
{
|
||||
var fileManifest = _versionFileManifest.FirstOrDefault(x => x.Name == Path.Combine(PackageDirectories[package.Name], entry.FullName));
|
||||
|
||||
if (fileManifest is not null && MD5Hash.FromFile(extractPath) == fileManifest.Signature)
|
||||
continue;
|
||||
|
||||
File.Delete(extractPath);
|
||||
}
|
||||
|
||||
entry.ExtractToFile(extractPath, true);
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,9 @@ global using Bloxstrap.Enums;
|
||||
global using Bloxstrap.Exceptions;
|
||||
global using Bloxstrap.Extensions;
|
||||
global using Bloxstrap.Models;
|
||||
global using Bloxstrap.Models.BloxstrapRPC;
|
||||
global using Bloxstrap.Models.Attributes;
|
||||
global using Bloxstrap.Models.BloxstrapRPC;
|
||||
global using Bloxstrap.Models.RobloxApi;
|
||||
global using Bloxstrap.Models.Manifest;
|
||||
global using Bloxstrap.UI;
|
||||
global using Bloxstrap.Utility;
|
33
Bloxstrap/Models/Manifest/FileManifest.cs
Normal file
33
Bloxstrap/Models/Manifest/FileManifest.cs
Normal file
@ -0,0 +1,33 @@
|
||||
namespace Bloxstrap.Models.Manifest
|
||||
{
|
||||
public class FileManifest : List<ManifestFile>
|
||||
{
|
||||
private FileManifest(string data)
|
||||
{
|
||||
using StringReader reader = new StringReader(data);
|
||||
|
||||
while (true)
|
||||
{
|
||||
string? fileName = reader.ReadLine();
|
||||
string? signature = reader.ReadLine();
|
||||
|
||||
if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(signature))
|
||||
break;
|
||||
|
||||
Add(new ManifestFile
|
||||
{
|
||||
Name = fileName,
|
||||
Signature = signature
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<FileManifest> Get(string versionGuid)
|
||||
{
|
||||
string pkgManifestUrl = RobloxDeployment.GetLocation($"/{versionGuid}-rbxManifest.txt");
|
||||
var pkgManifestData = await App.HttpClient.GetStringAsync(pkgManifestUrl);
|
||||
|
||||
return new FileManifest(pkgManifestData);
|
||||
}
|
||||
}
|
||||
}
|
13
Bloxstrap/Models/Manifest/ManifestFile.cs
Normal file
13
Bloxstrap/Models/Manifest/ManifestFile.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace Bloxstrap.Models.Manifest
|
||||
{
|
||||
public class ManifestFile
|
||||
{
|
||||
public string Name { get; set; } = "";
|
||||
public string Signature { get; set; } = "";
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{Signature}] {Name}";
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
* Copyright (c) 2015-present MaximumADHD
|
||||
*/
|
||||
|
||||
namespace Bloxstrap.Models
|
||||
namespace Bloxstrap.Models.Manifest
|
||||
{
|
||||
public class Package
|
||||
{
|
@ -4,7 +4,7 @@
|
||||
* Copyright (c) 2015-present MaximumADHD
|
||||
*/
|
||||
|
||||
namespace Bloxstrap.Models
|
||||
namespace Bloxstrap.Models.Manifest
|
||||
{
|
||||
public class PackageManifest : List<Package>
|
||||
{
|
Loading…
Reference in New Issue
Block a user