mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix issue with CHD-only dats
This commit is contained in:
@@ -58,6 +58,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
public List<DatItem> this[string key]
|
public List<DatItem> this[string key]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
{
|
||||||
|
// Explicit lock for some weird corner cases
|
||||||
|
lock (key)
|
||||||
{
|
{
|
||||||
// Ensure the key exists
|
// Ensure the key exists
|
||||||
EnsureKey(key);
|
EnsureKey(key);
|
||||||
@@ -66,6 +69,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
return Items[key];
|
return Items[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a value to the file dictionary
|
/// Add a value to the file dictionary
|
||||||
@@ -73,6 +77,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// <param name="key">Key in the dictionary to add to</param>
|
/// <param name="key">Key in the dictionary to add to</param>
|
||||||
/// <param name="value">Value to add to the dictionary</param>
|
/// <param name="value">Value to add to the dictionary</param>
|
||||||
public void Add(string key, DatItem value)
|
public void Add(string key, DatItem value)
|
||||||
|
{
|
||||||
|
// Explicit lock for some weird corner cases
|
||||||
|
lock (key)
|
||||||
{
|
{
|
||||||
// Ensure the key exists
|
// Ensure the key exists
|
||||||
EnsureKey(key);
|
EnsureKey(key);
|
||||||
@@ -87,6 +94,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Now update the statistics
|
// Now update the statistics
|
||||||
DatStats.AddItem(value);
|
DatStats.AddItem(value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a range of values to the file dictionary
|
/// Add a range of values to the file dictionary
|
||||||
@@ -94,6 +102,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// <param name="key">Key in the dictionary to add to</param>
|
/// <param name="key">Key in the dictionary to add to</param>
|
||||||
/// <param name="value">Value to add to the dictionary</param>
|
/// <param name="value">Value to add to the dictionary</param>
|
||||||
public void AddRange(string key, List<DatItem> value)
|
public void AddRange(string key, List<DatItem> value)
|
||||||
|
{
|
||||||
|
// Explicit lock for some weird corner cases
|
||||||
|
lock (key)
|
||||||
{
|
{
|
||||||
// Ensure the key exists
|
// Ensure the key exists
|
||||||
EnsureKey(key);
|
EnsureKey(key);
|
||||||
@@ -107,6 +118,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
DatStats.AddItem(item);
|
DatStats.AddItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get if the file dictionary contains the key
|
/// Get if the file dictionary contains the key
|
||||||
@@ -119,8 +131,12 @@ namespace SabreTools.Library.DatFiles
|
|||||||
if (key == null)
|
if (key == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Explicit lock for some weird corner cases
|
||||||
|
lock (key)
|
||||||
|
{
|
||||||
return Items.ContainsKey(key);
|
return Items.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get if the file dictionary contains the key and value
|
/// Get if the file dictionary contains the key and value
|
||||||
@@ -134,8 +150,12 @@ namespace SabreTools.Library.DatFiles
|
|||||||
if (key == null)
|
if (key == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Explicit lock for some weird corner cases
|
||||||
|
lock (key)
|
||||||
|
{
|
||||||
if (Items.ContainsKey(key))
|
if (Items.ContainsKey(key))
|
||||||
return Items[key].Contains(value);
|
return Items[key].Contains(value);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -804,13 +804,10 @@ namespace SabreTools.Library.DatFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock the list and add the item back
|
// Add the item to the output
|
||||||
lock (newitems)
|
|
||||||
{
|
|
||||||
newitems.Add(item);
|
newitems.Add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
datFile.Remove(key);
|
datFile.Remove(key);
|
||||||
datFile.AddRange(key, newitems);
|
datFile.AddRange(key, newitems);
|
||||||
|
|||||||
@@ -1116,8 +1116,10 @@ namespace SabreTools.Library.DatItems
|
|||||||
|
|
||||||
// Then deduplicate them by checking to see if data matches previous saved roms
|
// Then deduplicate them by checking to see if data matches previous saved roms
|
||||||
int nodumpCount = 0;
|
int nodumpCount = 0;
|
||||||
foreach (DatItem file in infiles)
|
for (int f = 0; f < infiles.Count; f++)
|
||||||
{
|
{
|
||||||
|
DatItem file = infiles[f];
|
||||||
|
|
||||||
// If we don't have a Rom or a Disk, we skip checking for duplicates
|
// If we don't have a Rom or a Disk, we skip checking for duplicates
|
||||||
if (file.ItemType != ItemType.Rom && file.ItemType != ItemType.Disk)
|
if (file.ItemType != ItemType.Rom && file.ItemType != ItemType.Disk)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user