Fix strip scene dates in DB variant

This commit is contained in:
Matt Nadareski
2025-01-13 00:02:56 -05:00
parent b62792d802
commit 208f4f64a9
2 changed files with 11 additions and 24 deletions

View File

@@ -1023,7 +1023,7 @@ namespace SabreTools.DatFiles
internal void StripSceneDatesFromItems() internal void StripSceneDatesFromItems()
{ {
// Set the regex pattern to use // Set the regex pattern to use
string pattern = @"([0-9]{2}\.[0-9]{2}\.[0-9]{2}-)(.*?-.*?)"; const string pattern = @"([0-9]{2}\.[0-9]{2}\.[0-9]{2}-)(.*?-.*?)";
// Now process all of the roms // Now process all of the roms
#if NET452_OR_GREATER || NETCOREAPP #if NET452_OR_GREATER || NETCOREAPP

View File

@@ -1398,42 +1398,29 @@ namespace SabreTools.DatFiles
internal void StripSceneDatesFromItems() internal void StripSceneDatesFromItems()
{ {
// Set the regex pattern to use // Set the regex pattern to use
string pattern = @"([0-9]{2}\.[0-9]{2}\.[0-9]{2}-)(.*?-.*?)"; const string pattern = @"([0-9]{2}\.[0-9]{2}\.[0-9]{2}-)(.*?-.*?)";
// Now process all of the roms // Now process all of the machines
#if NET452_OR_GREATER || NETCOREAPP #if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(SortedKeys, Core.Globals.ParallelOptions, key => Parallel.ForEach(GetMachines(), Core.Globals.ParallelOptions, machine =>
#elif NET40_OR_GREATER #elif NET40_OR_GREATER
Parallel.ForEach(SortedKeys, key => Parallel.ForEach(GetMachines(), machine =>
#else #else
foreach (var key in SortedKeys) foreach (var machine in GetMachines())
#endif #endif
{ {
var items = GetItemsForBucket(key); if (machine.Value == null)
if (items == null)
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
return; return;
#else #else
continue; continue;
#endif #endif
List<long> itemIds = [];
foreach (var item in items)
{
var machine = GetMachineForItem(item.Key);
if (machine.Value == null)
continue;
if (Regex.IsMatch(machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey)!, pattern)) if (Regex.IsMatch(machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey)!, pattern))
machine.Value.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, Regex.Replace(machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey)!, pattern, "$2")); machine.Value.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, Regex.Replace(machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey)!, pattern, "$2"));
if (Regex.IsMatch(machine.Value.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!, pattern)) if (Regex.IsMatch(machine.Value.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!, pattern))
machine.Value.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, Regex.Replace(machine.Value.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!, pattern, "$2")); machine.Value.SetFieldValue<string?>(Models.Metadata.Machine.DescriptionKey, Regex.Replace(machine.Value.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!, pattern, "$2"));
itemIds.Add(item.Key);
}
_buckets[key] = itemIds;
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
}); });
#else #else