Fix duplication issue

This commit is contained in:
Matt Nadareski
2020-08-30 17:02:07 -07:00
parent 89f9ee0faf
commit 2921f01494
2 changed files with 40 additions and 24 deletions

View File

@@ -3495,7 +3495,7 @@ namespace SabreTools.Library.DatFiles
Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: norename); Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: norename);
// Output the number of items we're going to be writing // Output the number of items we're going to be writing
Globals.Logger.User($"A total of {Items.TotalCount} items will be written out to '{Header.FileName}'"); Globals.Logger.User($"A total of {Items.TotalCount - Items.RemovedCount} items will be written out to '{Header.FileName}'");
// Get the outfile names // Get the outfile names
Dictionary<DatFormat, string> outfiles = Header.CreateOutFileNames(outDir, overwrite); Dictionary<DatFormat, string> outfiles = Header.CreateOutFileNames(outDir, overwrite);

View File

@@ -199,6 +199,12 @@ namespace SabreTools.Library.DatFiles
[JsonIgnore] [JsonIgnore]
public long NodumpCount { get; private set; } = 0; public long NodumpCount { get; private set; } = 0;
/// <summary>
/// Number of items with the remove flag
/// </summary>
[JsonIgnore]
public long RemovedCount { get; private set; } = 0;
/// <summary> /// <summary>
/// Number of items with the verified status /// Number of items with the verified status
/// </summary> /// </summary>
@@ -233,6 +239,7 @@ namespace SabreTools.Library.DatFiles
} }
set set
{ {
Remove(key);
AddRange(key, value); AddRange(key, value);
} }
} }
@@ -434,23 +441,27 @@ namespace SabreTools.Library.DatFiles
/// <param name="item">Item to add info from</param> /// <param name="item">Item to add info from</param>
private void AddItemStatistics(DatItem item) private void AddItemStatistics(DatItem item)
{ {
// No matter what the item is, we increate the count // No matter what the item is, we increment the count
TotalCount += 1; TotalCount++;
// Increment removal count
if (item.Remove)
RemovedCount++;
// Now we do different things for each item type // Now we do different things for each item type
switch (item.ItemType) switch (item.ItemType)
{ {
case ItemType.Archive: case ItemType.Archive:
ArchiveCount += 1; ArchiveCount++;
break; break;
case ItemType.BiosSet: case ItemType.BiosSet:
BiosSetCount += 1; BiosSetCount++;
break; break;
case ItemType.Chip: case ItemType.Chip:
ChipCount += 1; ChipCount++;
break; break;
case ItemType.Disk: case ItemType.Disk:
DiskCount += 1; DiskCount++;
if ((item as Disk).ItemStatus != ItemStatus.Nodump) if ((item as Disk).ItemStatus != ItemStatus.Nodump)
{ {
MD5Count += (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1); MD5Count += (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
@@ -463,16 +474,16 @@ namespace SabreTools.Library.DatFiles
VerifiedCount += ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0); VerifiedCount += ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
break; break;
case ItemType.Media: case ItemType.Media:
MediaCount += 1; MediaCount++;
MD5Count += (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1); MD5Count += (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1);
SHA1Count += (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1); SHA1Count += (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
SHA256Count += (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1); SHA256Count += (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
break; break;
case ItemType.Release: case ItemType.Release:
ReleaseCount += 1; ReleaseCount++;
break; break;
case ItemType.Rom: case ItemType.Rom:
RomCount += 1; RomCount++;
if ((item as Rom).ItemStatus != ItemStatus.Nodump) if ((item as Rom).ItemStatus != ItemStatus.Nodump)
{ {
TotalSize += (item as Rom).Size; TotalSize += (item as Rom).Size;
@@ -493,7 +504,7 @@ namespace SabreTools.Library.DatFiles
VerifiedCount += ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0); VerifiedCount += ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0);
break; break;
case ItemType.Sample: case ItemType.Sample:
SampleCount += 1; SampleCount++;
break; break;
} }
} }
@@ -534,6 +545,7 @@ namespace SabreTools.Library.DatFiles
BaddumpCount += stats.BaddumpCount; BaddumpCount += stats.BaddumpCount;
GoodCount += stats.GoodCount; GoodCount += stats.GoodCount;
NodumpCount += stats.NodumpCount; NodumpCount += stats.NodumpCount;
RemovedCount += stats.RemovedCount;
VerifiedCount += stats.VerifiedCount; VerifiedCount += stats.VerifiedCount;
} }
@@ -558,24 +570,27 @@ namespace SabreTools.Library.DatFiles
if (item == null) if (item == null)
return; return;
// No matter what the item is, we increate the count // No matter what the item is, we decrease the count
TotalCount -= 1; TotalCount--;
// Decrement removal count
if (item.Remove)
RemovedCount--;
// Now we do different things for each item type // Now we do different things for each item type
switch (item.ItemType) switch (item.ItemType)
{ {
case ItemType.Archive: case ItemType.Archive:
ArchiveCount -= 1; ArchiveCount--;
break; break;
case ItemType.BiosSet: case ItemType.BiosSet:
BiosSetCount -= 1; BiosSetCount--;
break; break;
case ItemType.Chip: case ItemType.Chip:
ChipCount -= 1; ChipCount--;
break; break;
case ItemType.Disk: case ItemType.Disk:
DiskCount -= 1; DiskCount--;
if ((item as Disk).ItemStatus != ItemStatus.Nodump) if ((item as Disk).ItemStatus != ItemStatus.Nodump)
{ {
MD5Count -= (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1); MD5Count -= (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
@@ -588,16 +603,16 @@ namespace SabreTools.Library.DatFiles
VerifiedCount -= ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0); VerifiedCount -= ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
break; break;
case ItemType.Media: case ItemType.Media:
MediaCount -= 1; MediaCount--;
MD5Count -= (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1); MD5Count -= (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1);
SHA1Count -= (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1); SHA1Count -= (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
SHA256Count -= (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1); SHA256Count -= (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
break; break;
case ItemType.Release: case ItemType.Release:
ReleaseCount -= 1; ReleaseCount--;
break; break;
case ItemType.Rom: case ItemType.Rom:
RomCount -= 1; RomCount--;
if ((item as Rom).ItemStatus != ItemStatus.Nodump) if ((item as Rom).ItemStatus != ItemStatus.Nodump)
{ {
TotalSize -= (item as Rom).Size; TotalSize -= (item as Rom).Size;
@@ -618,7 +633,7 @@ namespace SabreTools.Library.DatFiles
VerifiedCount -= ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0); VerifiedCount -= ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0);
break; break;
case ItemType.Sample: case ItemType.Sample:
SampleCount -= 1; SampleCount--;
break; break;
} }
} }
@@ -864,14 +879,14 @@ namespace SabreTools.Library.DatFiles
return; return;
// Loop through and add // Loop through and add
Parallel.ForEach(items.Keys, Globals.ParallelOptions, key => foreach (string key in items.Keys)
{ {
List<DatItem> datItems = items[key]; List<DatItem> datItems = items[key];
foreach (DatItem item in datItems) foreach (DatItem item in datItems)
{ {
AddItemStatistics(item); AddItemStatistics(item);
} }
}); }
} }
/// <summary> /// <summary>
@@ -943,6 +958,7 @@ namespace SabreTools.Library.DatFiles
BaddumpCount = 0; BaddumpCount = 0;
GoodCount = 0; GoodCount = 0;
NodumpCount = 0; NodumpCount = 0;
RemovedCount = 0;
VerifiedCount = 0; VerifiedCount = 0;
} }