Merge pull request #1094 from Unnoen/reduce-compress-work

Don't attempt to compress files smaller than the disk cluster size.
This commit is contained in:
Timothy Baldridge 2020-09-17 23:48:56 -06:00 committed by GitHub
commit 30b85bb442
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using Wabbajack.Common.IO;
namespace Wabbajack.Common
@ -60,7 +61,12 @@ namespace Wabbajack.Common
public static async Task CompactFolder(this AbsolutePath folder, WorkQueue queue, Algorithm algorithm)
{
await folder.EnumerateFiles(true)
var driveInfo = folder.DriveInfo().DiskSpaceInfo;
var clusterSize = driveInfo.SectorsPerCluster * driveInfo.BytesPerSector;
await folder
.EnumerateFiles(true)
.Where(f => f.Size > clusterSize)
.PMap(queue, async path =>
{
Utils.Status($"Compacting {path.FileName}");