From 4b837d83bbb5895307125230e1833cd27a1a24fb Mon Sep 17 00:00:00 2001 From: Unnoen Date: Thu, 17 Sep 2020 22:49:41 +1000 Subject: [PATCH 1/2] Don't attempt to compress files smaller than the cluster size. --- Wabbajack.Common/Paths/FileCompaction.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Wabbajack.Common/Paths/FileCompaction.cs b/Wabbajack.Common/Paths/FileCompaction.cs index cd5bbaf3..37d47a1b 100644 --- a/Wabbajack.Common/Paths/FileCompaction.cs +++ b/Wabbajack.Common/Paths/FileCompaction.cs @@ -60,11 +60,17 @@ namespace Wabbajack.Common public static async Task CompactFolder(this AbsolutePath folder, WorkQueue queue, Algorithm algorithm) { + var driveInfo = folder.DriveInfo().DiskSpaceInfo; + var clusterSize = driveInfo.SectorsPerCluster * driveInfo.BytesPerSector; + await folder.EnumerateFiles(true) .PMap(queue, async path => { - Utils.Status($"Compacting {path.FileName}"); - await path.Compact(algorithm); + if (path.Size > clusterSize) + { + Utils.Status($"Compacting {path.FileName}"); + await path.Compact(algorithm); + } }); } } From 7b1812af873a92845b4a7d79101521c290b6459f Mon Sep 17 00:00:00 2001 From: Unnoen Date: Fri, 18 Sep 2020 00:08:30 +1000 Subject: [PATCH 2/2] Use .Where for filtering --- Wabbajack.Common/Paths/FileCompaction.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Wabbajack.Common/Paths/FileCompaction.cs b/Wabbajack.Common/Paths/FileCompaction.cs index 37d47a1b..be6a16be 100644 --- a/Wabbajack.Common/Paths/FileCompaction.cs +++ b/Wabbajack.Common/Paths/FileCompaction.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Linq; +using System.Threading.Tasks; using Wabbajack.Common.IO; namespace Wabbajack.Common @@ -63,14 +64,13 @@ namespace Wabbajack.Common var driveInfo = folder.DriveInfo().DiskSpaceInfo; var clusterSize = driveInfo.SectorsPerCluster * driveInfo.BytesPerSector; - await folder.EnumerateFiles(true) + await folder + .EnumerateFiles(true) + .Where(f => f.Size > clusterSize) .PMap(queue, async path => { - if (path.Size > clusterSize) - { - Utils.Status($"Compacting {path.FileName}"); - await path.Compact(algorithm); - } + Utils.Status($"Compacting {path.FileName}"); + await path.Compact(algorithm); }); } }