From e76d19033fd0c84b34bf9a4c97c8ab0c2d60f24c Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 28 Aug 2020 21:10:02 -0700 Subject: [PATCH] Implement partial packing --- SabreTools.Library/DatFiles/DatFile.cs | 18 ++++++++++++++++++ SabreTools.Library/DatItems/DatItem.cs | 1 - 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index b6db17c3..20359d70 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -2479,6 +2479,10 @@ namespace SabreTools.Library.DatFiles if (fileinfo == null) continue; + // If we have partial, just ensure we are sorted correctly + if (outputFormat == OutputFormat.Folder && Header.ForcePacking == PackingFlag.Partial) + Items.BucketBy(Field.DatItem_SHA1, DedupeType.None); + // If there are no items in the hash, we continue if (Items[hash] == null || Items[hash].Count == 0) continue; @@ -2909,9 +2913,23 @@ namespace SabreTools.Library.DatFiles Globals.Logger.User($"{(inverse ? "No matches" : "Matches")} found for '{Path.GetFileName(datItem.Name)}', rebuilding accordingly..."); rebuilt = true; + // Special case for partial packing mode + bool shouldCheck = false; + if (outputFormat == OutputFormat.Folder && Header.ForcePacking == PackingFlag.Partial) + { + shouldCheck = true; + Items.BucketBy(Field.Machine_Name, DedupeType.None, lower: false); + } + // Now loop through the list and rebuild accordingly foreach (DatItem item in dupes) { + // If we should check for the items in the machine + if (shouldCheck && Items[item.Machine.Name].Count > 1) + outputFormat = OutputFormat.Folder; + else if (shouldCheck && Items[item.Machine.Name].Count == 1) + outputFormat = OutputFormat.ParentFolder; + // Get the output archive, if possible Folder outputArchive = Folder.Create(outputFormat); diff --git a/SabreTools.Library/DatItems/DatItem.cs b/SabreTools.Library/DatItems/DatItem.cs index e5058522..3516ddf5 100644 --- a/SabreTools.Library/DatItems/DatItem.cs +++ b/SabreTools.Library/DatItems/DatItem.cs @@ -854,7 +854,6 @@ namespace SabreTools.Library.DatItems if (key == null) key = "null"; - key = WebUtility.HtmlEncode(key); break; case Field.DatItem_MD5: