Take existing files into account when calculating sizes.

This commit is contained in:
Timothy Baldridge 2019-11-23 17:04:34 -07:00
parent d65060b796
commit 4ec2580ca4
2 changed files with 6 additions and 3 deletions

View File

@ -86,10 +86,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter">
<Version>1.3.2</Version>
<Version>2.0.0</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>1.3.2</Version>
<Version>2.0.0</Version>
</PackageReference>
<PackageReference Include="System.Reactive">
<Version>4.2.0</Version>

View File

@ -297,8 +297,11 @@ namespace Wabbajack.Lib
.Do(g =>
{
var required = g.Sum(i => i.Item2);
var contains = g.Sum(folder =>
Directory.EnumerateFiles(folder.Item1, "*", DirectoryEnumerationOptions.Recursive)
.Sum(file => new FileInfo(file).Length));
var available = DriveInfo(g.Key).FreeBytesAvailable;
if (required > available)
if (required - contains > available)
throw new NotEnoughDiskSpaceException(
$"This modlist requires {required.ToFileSizeString()} on {g.Key} but only {available.ToFileSizeString()} is available.");
});