mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Sync constructors between Item dicts
This commit is contained in:
@@ -27,12 +27,12 @@ namespace SabreTools.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determine the bucketing key for all items
|
/// Determine the bucketing key for all items
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ItemKey _bucketedBy;
|
private ItemKey _bucketedBy = ItemKey.NULL;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determine merging type for all items
|
/// Determine merging type for all items
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private DedupeType _mergedBy;
|
private DedupeType _mergedBy = DedupeType.None;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal dictionary for the class
|
/// Internal dictionary for the class
|
||||||
@@ -82,8 +82,6 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ItemDictionary()
|
public ItemDictionary()
|
||||||
{
|
{
|
||||||
_bucketedBy = ItemKey.NULL;
|
|
||||||
_mergedBy = DedupeType.None;
|
|
||||||
_logger = new Logger(this);
|
_logger = new Logger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using SabreTools.Core.Tools;
|
|||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
using SabreTools.Hashing;
|
using SabreTools.Hashing;
|
||||||
|
using SabreTools.IO.Logging;
|
||||||
using SabreTools.Matching.Compare;
|
using SabreTools.Matching.Compare;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -128,6 +129,11 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ItemKey _bucketedBy = ItemKey.NULL;
|
private ItemKey _bucketedBy = ItemKey.NULL;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logging object
|
||||||
|
/// </summary>
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
@@ -155,10 +161,17 @@ namespace SabreTools.DatFiles
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generic constructor
|
/// Generic constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ItemDictionaryDB() { }
|
public ItemDictionaryDB()
|
||||||
|
{
|
||||||
|
_logger = new Logger(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Accessors
|
#region Accessors
|
||||||
|
|
||||||
@@ -180,6 +193,7 @@ namespace SabreTools.DatFiles
|
|||||||
&& string.IsNullOrEmpty(disk.GetStringFieldValue(Models.Metadata.Disk.MD5Key))
|
&& string.IsNullOrEmpty(disk.GetStringFieldValue(Models.Metadata.Disk.MD5Key))
|
||||||
&& string.IsNullOrEmpty(disk.GetStringFieldValue(Models.Metadata.Disk.SHA1Key)))
|
&& string.IsNullOrEmpty(disk.GetStringFieldValue(Models.Metadata.Disk.SHA1Key)))
|
||||||
{
|
{
|
||||||
|
_logger.Verbose($"Incomplete entry for '{disk.GetName()}' will be output as nodump");
|
||||||
disk.SetFieldValue<string?>(Models.Metadata.Disk.StatusKey, ItemStatus.Nodump.AsStringValue());
|
disk.SetFieldValue<string?>(Models.Metadata.Disk.StatusKey, ItemStatus.Nodump.AsStringValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +207,7 @@ namespace SabreTools.DatFiles
|
|||||||
&& string.IsNullOrEmpty(media.GetStringFieldValue(Models.Metadata.Media.SHA256Key))
|
&& string.IsNullOrEmpty(media.GetStringFieldValue(Models.Metadata.Media.SHA256Key))
|
||||||
&& string.IsNullOrEmpty(media.GetStringFieldValue(Models.Metadata.Media.SpamSumKey)))
|
&& string.IsNullOrEmpty(media.GetStringFieldValue(Models.Metadata.Media.SpamSumKey)))
|
||||||
{
|
{
|
||||||
// No-op as there is no status key for Media
|
_logger.Verbose($"Incomplete entry for '{media.GetName()}' will be output as nodump");
|
||||||
}
|
}
|
||||||
|
|
||||||
item = media;
|
item = media;
|
||||||
@@ -206,6 +220,7 @@ namespace SabreTools.DatFiles
|
|||||||
if (size == null && !rom.HasHashes())
|
if (size == null && !rom.HasHashes())
|
||||||
{
|
{
|
||||||
// No-op, just catch it so it doesn't go further
|
// No-op, just catch it so it doesn't go further
|
||||||
|
//logger.Verbose($"{Header.GetStringFieldValue(DatHeader.FileNameKey)}: Entry with only SHA-1 found - '{rom.GetName()}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info
|
// If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info
|
||||||
@@ -227,6 +242,7 @@ namespace SabreTools.DatFiles
|
|||||||
// If the file has no size and it's not the above case, skip and log
|
// If the file has no size and it's not the above case, skip and log
|
||||||
else if (rom.GetStringFieldValue(Models.Metadata.Rom.StatusKey).AsEnumValue<ItemStatus>() != ItemStatus.Nodump && (size == 0 || size == null))
|
else if (rom.GetStringFieldValue(Models.Metadata.Rom.StatusKey).AsEnumValue<ItemStatus>() != ItemStatus.Nodump && (size == 0 || size == null))
|
||||||
{
|
{
|
||||||
|
//logger.Verbose($"{Header.GetStringFieldValue(DatHeader.FileNameKey)}: Incomplete entry for '{rom.GetName()}' will be output as nodump");
|
||||||
rom.SetFieldValue<string?>(Models.Metadata.Rom.StatusKey, ItemStatus.Nodump.AsStringValue());
|
rom.SetFieldValue<string?>(Models.Metadata.Rom.StatusKey, ItemStatus.Nodump.AsStringValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,6 +251,7 @@ namespace SabreTools.DatFiles
|
|||||||
&& size != null && size > 0
|
&& size != null && size > 0
|
||||||
&& !rom.HasHashes())
|
&& !rom.HasHashes())
|
||||||
{
|
{
|
||||||
|
//logger.Verbose($"{Header.GetStringFieldValue(DatHeader.FileNameKey)}: Incomplete entry for '{rom.GetName()}' will be output as nodump");
|
||||||
rom.SetFieldValue<string?>(Models.Metadata.Rom.StatusKey, ItemStatus.Nodump.AsStringValue());
|
rom.SetFieldValue<string?>(Models.Metadata.Rom.StatusKey, ItemStatus.Nodump.AsStringValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,16 +701,21 @@ namespace SabreTools.DatFiles
|
|||||||
{
|
{
|
||||||
// If the sorted type isn't the same, we want to sort the dictionary accordingly
|
// If the sorted type isn't the same, we want to sort the dictionary accordingly
|
||||||
if (_bucketedBy != bucketBy && bucketBy != ItemKey.NULL)
|
if (_bucketedBy != bucketBy && bucketBy != ItemKey.NULL)
|
||||||
|
{
|
||||||
|
_logger.User($"Organizing roms by {bucketBy}");
|
||||||
PerformBucketing(bucketBy, lower, norename);
|
PerformBucketing(bucketBy, lower, norename);
|
||||||
|
}
|
||||||
|
|
||||||
// If the merge type isn't the same, we want to merge the dictionary accordingly
|
// If the merge type isn't the same, we want to merge the dictionary accordingly
|
||||||
if (dedupeType != DedupeType.None)
|
if (dedupeType != DedupeType.None)
|
||||||
{
|
{
|
||||||
|
_logger.User($"Deduping roms by {dedupeType}");
|
||||||
PerformDeduplication(bucketBy, dedupeType);
|
PerformDeduplication(bucketBy, dedupeType);
|
||||||
}
|
}
|
||||||
// If the merge type is the same, we want to sort the dictionary to be consistent
|
// If the merge type is the same, we want to sort the dictionary to be consistent
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_logger.User($"Sorting roms by {bucketBy}");
|
||||||
PerformSorting(norename);
|
PerformSorting(norename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user