From 4ec2580ca449ef62c06247249d8e89561e89a431 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Sat, 23 Nov 2019 17:04:34 -0700 Subject: [PATCH] Take existing files into account when calculating sizes. --- Wabbajack.CacheServer.Test/Wabbajack.CacheServer.Test.csproj | 4 ++-- Wabbajack.Lib/AInstaller.cs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Wabbajack.CacheServer.Test/Wabbajack.CacheServer.Test.csproj b/Wabbajack.CacheServer.Test/Wabbajack.CacheServer.Test.csproj index d3e0ed9f..ada745bb 100644 --- a/Wabbajack.CacheServer.Test/Wabbajack.CacheServer.Test.csproj +++ b/Wabbajack.CacheServer.Test/Wabbajack.CacheServer.Test.csproj @@ -86,10 +86,10 @@ - 1.3.2 + 2.0.0 - 1.3.2 + 2.0.0 4.2.0 diff --git a/Wabbajack.Lib/AInstaller.cs b/Wabbajack.Lib/AInstaller.cs index a17a7983..7749dd1c 100644 --- a/Wabbajack.Lib/AInstaller.cs +++ b/Wabbajack.Lib/AInstaller.cs @@ -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."); });