mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add AddItem tests
This commit is contained in:
@@ -182,7 +182,7 @@ namespace SabreTools.DatFiles
|
||||
/// <returns>The index for the added item, -1 on error</returns>
|
||||
public long AddItem(DatItem item, long machineIndex, long sourceIndex, bool statsOnly)
|
||||
{
|
||||
// If we have a Disk, Media, or Rom, clean the hash data
|
||||
// If we have a Disk, File, Media, or Rom, clean the hash data
|
||||
if (item is Disk disk)
|
||||
{
|
||||
// If the file has aboslutely no hashes, skip and log
|
||||
@@ -196,6 +196,19 @@ namespace SabreTools.DatFiles
|
||||
|
||||
item = disk;
|
||||
}
|
||||
else if (item is DatItems.Formats.File file)
|
||||
{
|
||||
// If the file has aboslutely no hashes, skip and log
|
||||
if (string.IsNullOrEmpty(file.CRC)
|
||||
&& string.IsNullOrEmpty(file.MD5)
|
||||
&& string.IsNullOrEmpty(file.SHA1)
|
||||
&& string.IsNullOrEmpty(file.SHA256))
|
||||
{
|
||||
_logger.Verbose($"Incomplete entry for '{file.GetName()}' will be output as nodump");
|
||||
}
|
||||
|
||||
item = file;
|
||||
}
|
||||
else if (item is Media media)
|
||||
{
|
||||
// If the file has aboslutely no hashes, skip and log
|
||||
@@ -214,7 +227,7 @@ namespace SabreTools.DatFiles
|
||||
long? size = rom.GetInt64FieldValue(Models.Metadata.Rom.SizeKey);
|
||||
|
||||
// If we have the case where there is SHA-1 and nothing else, we don't fill in any other part of the data
|
||||
if (size == null && !rom.HasHashes())
|
||||
if (size == null && !string.IsNullOrEmpty(rom.GetStringFieldValue(Models.Metadata.Rom.SHA1Key)))
|
||||
{
|
||||
// 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()}'");
|
||||
|
||||
Reference in New Issue
Block a user