Check disk space based on manifest sizes

This commit is contained in:
pizzaboxer 2023-04-26 14:04:27 +01:00
parent 580173d31c
commit 903fc42128
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8

View File

@ -659,10 +659,14 @@ namespace Bloxstrap
SetStatus(FreshInstall ? "Installing Roblox..." : "Upgrading Roblox..."); SetStatus(FreshInstall ? "Installing Roblox..." : "Upgrading Roblox...");
// check if we have at least 300 megabytes of free disk space // package manifest states packed size and uncompressed size in exact bytes
if (Utilities.GetFreeDiskSpace(Directories.Base) < 1024*1024*300) // packed size only matters if we don't already have the package cached on disk
string[] cachedPackages = Directory.GetFiles(Directories.Downloads);
int totalSizeRequired = _versionPackageManifest.Where(x => !cachedPackages.Contains(x.Signature)).Sum(x => x.PackedSize) + _versionPackageManifest.Sum(x => x.Size);
if (Utilities.GetFreeDiskSpace(Directories.Base) < totalSizeRequired)
{ {
App.ShowMessageBox($"{App.ProjectName} requires at least 300 MB of disk space to install Roblox. Please free up some disk space and try again.", MessageBoxImage.Error); App.ShowMessageBox($"{App.ProjectName} does not have enough disk space to download and install Roblox. Please free up some disk space and try again.", MessageBoxImage.Error);
App.Terminate(ERROR_INSTALL_FAILURE); App.Terminate(ERROR_INSTALL_FAILURE);
return; return;
} }
@ -727,7 +731,7 @@ namespace Bloxstrap
ReShade.SynchronizeConfigFile(); ReShade.SynchronizeConfigFile();
// let's take this opportunity to delete any packages we don't need anymore // let's take this opportunity to delete any packages we don't need anymore
foreach (string filename in Directory.GetFiles(Directories.Downloads)) foreach (string filename in cachedPackages)
{ {
if (!_versionPackageManifest.Exists(package => filename.Contains(package.Signature))) if (!_versionPackageManifest.Exists(package => filename.Contains(package.Signature)))
{ {