Fix standard merging; dedupe still broken

This commit is contained in:
Matt Nadareski
2016-04-27 11:44:14 -07:00
parent e450eebfd7
commit 40b7d64303

View File

@@ -451,6 +451,9 @@ namespace SabreTools.Helper
Int64.TryParse(xtr.GetAttribute("size"), out size); Int64.TryParse(xtr.GetAttribute("size"), out size);
} }
// If we're in merged mode, check before adding
if (merge)
{
// If the rom doesn't exist, add it to the database // If the rom doesn't exist, add it to the database
string query = @"SELECT sha1 FROM roms WHERE size=" + size + string query = @"SELECT sha1 FROM roms WHERE size=" + size +
(xtr.GetAttribute("crc") != null ? " AND crc='" + xtr.GetAttribute("crc").ToLowerInvariant().Trim() + "'" : "") + (xtr.GetAttribute("crc") != null ? " AND crc='" + xtr.GetAttribute("crc").ToLowerInvariant().Trim() + "'" : "") +
@@ -498,6 +501,27 @@ VALUES ('" + tempname.Replace("'", "''") + "', '" +
} }
} }
} }
}
// If we're not in merged mode, just add it
else
{
string query = @"INSERT INTO roms
(game, name, type, sysid, srcid, size, crc, md5, sha1)
VALUES ('" + tempname.Replace("'", "''") + "', '" +
xtr.GetAttribute("name").Replace("'", "''") + "', '" +
xtr.Name + "', " +
sysid + ", " +
srcid + ", " +
size +
(xtr.GetAttribute("crc") != null ? ", '" + xtr.GetAttribute("crc").ToLowerInvariant().Trim() + "'" : ", ''") +
(xtr.GetAttribute("md5") != null ? ", '" + xtr.GetAttribute("md5").ToLowerInvariant().Trim() + "'" : ", ''") +
(xtr.GetAttribute("sha1") != null ? ", '" + xtr.GetAttribute("sha1").ToLowerInvariant().Trim() + "'" : ", ''") +
")";
using (SqliteCommand sslc = new SqliteCommand(query, dbc))
{
sslc.ExecuteNonQuery();
}
}
break; break;
} }