mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile, Disk, Rom] Better equality checking
This commit is contained in:
@@ -1468,19 +1468,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// If the key is different, move the item to the new key
|
// If the key is different, move the item to the new key
|
||||||
if (newkey != key)
|
if (newkey != key)
|
||||||
{
|
{
|
||||||
// We have to circumvent the proper process here because of issues with nodumps
|
Add(newkey, rom);
|
||||||
// TODO: Properly handle nodumps in key-to-key transfers
|
Remove(key, rom);
|
||||||
if (_items.ContainsKey(newkey))
|
|
||||||
{
|
|
||||||
_items[newkey].Add(rom);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_items.Add(newkey, new List<DatItem>() { rom });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now remove the rom from its original location
|
|
||||||
roms.RemoveAt(i);
|
|
||||||
i--; // This make sure that the pointer stays on the correct since one was removed
|
i--; // This make sure that the pointer stays on the correct since one was removed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,14 +138,20 @@ namespace SabreTools.Library.DatItems
|
|||||||
// Otherwise, treat it as a rom
|
// Otherwise, treat it as a rom
|
||||||
Disk newOther = (Disk)other;
|
Disk newOther = (Disk)other;
|
||||||
|
|
||||||
// If either is a nodump, it's never a match
|
// If all hashes are empty but they're both nodump and the names match, then they're dupes
|
||||||
if (_itemStatus == ItemStatus.Nodump || newOther.ItemStatus == ItemStatus.Nodump)
|
if ((this._itemStatus == ItemStatus.Nodump && newOther._itemStatus == ItemStatus.Nodump)
|
||||||
|
&& (this._name == newOther._name)
|
||||||
|
&& (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace())
|
||||||
|
&& (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace())
|
||||||
|
&& (this._sha256.IsNullOrWhiteSpace() && newOther._sha256.IsNullOrWhiteSpace())
|
||||||
|
&& (this._sha384.IsNullOrWhiteSpace() && newOther._sha384.IsNullOrWhiteSpace())
|
||||||
|
&& (this._sha512.IsNullOrWhiteSpace() && newOther._sha512.IsNullOrWhiteSpace()))
|
||||||
{
|
{
|
||||||
return dupefound;
|
dupefound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we can determine that the disks have no non-empty hashes in common, we return false
|
// If we can determine that the disks have no non-empty hashes in common, we return false
|
||||||
if ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
else if ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
||||||
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
||||||
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
||||||
&& (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
|
&& (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
|
||||||
@@ -153,6 +159,8 @@ namespace SabreTools.Library.DatItems
|
|||||||
{
|
{
|
||||||
dupefound = false;
|
dupefound = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise if we get a partial match
|
||||||
else if (((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
else if (((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||||
&& ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
&& ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||||
&& ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
&& ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||||
|
|||||||
@@ -205,14 +205,21 @@ namespace SabreTools.Library.DatItems
|
|||||||
// Otherwise, treat it as a rom
|
// Otherwise, treat it as a rom
|
||||||
Rom newOther = (Rom)other;
|
Rom newOther = (Rom)other;
|
||||||
|
|
||||||
// If either is a nodump, it's never a match
|
// If all hashes are empty but they're both nodump and the names match, then they're dupes
|
||||||
if (_itemStatus == ItemStatus.Nodump || newOther.ItemStatus == ItemStatus.Nodump)
|
if ((this._itemStatus == ItemStatus.Nodump && newOther._itemStatus == ItemStatus.Nodump)
|
||||||
|
&& (this._name == newOther._name)
|
||||||
|
&& (this._crc.IsNullOrWhiteSpace() && newOther._crc.IsNullOrWhiteSpace())
|
||||||
|
&& (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace())
|
||||||
|
&& (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace())
|
||||||
|
&& (this._sha256.IsNullOrWhiteSpace() && newOther._sha256.IsNullOrWhiteSpace())
|
||||||
|
&& (this._sha384.IsNullOrWhiteSpace() && newOther._sha384.IsNullOrWhiteSpace())
|
||||||
|
&& (this._sha512.IsNullOrWhiteSpace() && newOther._sha512.IsNullOrWhiteSpace()))
|
||||||
{
|
{
|
||||||
return dupefound;
|
dupefound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we can determine that the roms have no non-empty hashes in common, we return false
|
// If we can determine that the roms have no non-empty hashes in common, we return false
|
||||||
if ((_crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace())
|
else if ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace())
|
||||||
&& (this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
&& (this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
||||||
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
||||||
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
||||||
@@ -221,6 +228,8 @@ namespace SabreTools.Library.DatItems
|
|||||||
{
|
{
|
||||||
dupefound = false;
|
dupefound = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise if we get a partial match
|
||||||
else if ((this.Size == newOther.Size)
|
else if ((this.Size == newOther.Size)
|
||||||
&& ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._crc, newOther._crc))
|
&& ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._crc, newOther._crc))
|
||||||
&& ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
&& ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||||
|
|||||||
Reference in New Issue
Block a user