diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index de37756b..e23fa929 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -1948,7 +1948,8 @@ namespace SabreTools.Library.DatFiles Items.BucketBy(BucketedBy.SHA1, DedupeType.None); // Then we want to loop through each of the hashes and see if we can rebuild - foreach (string hash in Items.Keys) + var keys = Items.SortedKeys.ToList(); + foreach (string hash in keys) { // Pre-empt any issues that could arise from string length if (hash.Length != Constants.SHA1Length) @@ -1982,6 +1983,10 @@ namespace SabreTools.Library.DatFiles if (fileinfo == null) continue; + // If there are no items in the hash, we continue + if (Items[hash] == null || Items[hash].Count == 0) + continue; + // Otherwise, we rebuild that file to all locations that we need to bool usedInternally; if (Items[hash][0].ItemType == ItemType.Disk)