From 0d22715fa45b03693c377f4157a9b86b6993d0ba Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 27 Apr 2016 11:54:27 -0700 Subject: [PATCH] Remove unnecessary switch --- SabreHelper/RomManipulation.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/SabreHelper/RomManipulation.cs b/SabreHelper/RomManipulation.cs index 1ee6369d..7aea7575 100644 --- a/SabreHelper/RomManipulation.cs +++ b/SabreHelper/RomManipulation.cs @@ -455,11 +455,10 @@ namespace SabreTools.Helper if (merge) { // If the rom doesn't exist, add it to the database - string query = @"SELECT sha1 FROM roms WHERE size=" + size + - (xtr.GetAttribute("crc") != null ? " AND crc='" + xtr.GetAttribute("crc").ToLowerInvariant().Trim() + "'" : "") + - (xtr.GetAttribute("md5") != null ? " AND md5='" + xtr.GetAttribute("md5").ToLowerInvariant().Trim() + "'" : "") + - (xtr.GetAttribute("sha1") != null ? " AND sha1='" + xtr.GetAttribute("sha1").ToLowerInvariant().Trim() + "'" : "") + - (merge ? "" : " AND game='" + tempname.Replace("'", "''") + "' AND name='" + xtr.GetAttribute("name").Replace("'", "''") + "' AND sysid=" + sysid + " AND srcid=" + srcid); + string query = @"SELECT id FROM roms WHERE size=" + size + + (xtr.GetAttribute("crc") != null ? " AND (crc='" + xtr.GetAttribute("crc").ToLowerInvariant().Trim() + "' OR crc='')" : "") + + (xtr.GetAttribute("md5") != null ? " AND (md5='" + xtr.GetAttribute("md5").ToLowerInvariant().Trim() + "' OR md5='')" : "") + + (xtr.GetAttribute("sha1") != null ? " AND (sha1='" + xtr.GetAttribute("sha1").ToLowerInvariant().Trim() + "' OR sha1='')" : ""); using (SqliteCommand slc = new SqliteCommand(query, dbc)) { @@ -491,8 +490,7 @@ VALUES ('" + tempname.Replace("'", "''") + "', '" + query = @"UPDATE roms SET dupe='true' WHERE size=" + size + (xtr.GetAttribute("crc") != null ? " AND crc='" + xtr.GetAttribute("crc").ToLowerInvariant().Trim() + "'" : "") + (xtr.GetAttribute("md5") != null ? " AND md5='" + xtr.GetAttribute("md5").ToLowerInvariant().Trim() + "'" : "") + - (xtr.GetAttribute("sha1") != null ? " AND sha1='" + xtr.GetAttribute("sha1").ToLowerInvariant().Trim() + "'" : "") + - (merge ? "" : " AND game='" + tempname.Replace("'", "''") + "' AND name='" + xtr.GetAttribute("name").Replace("'", "''") + "' AND sysid=" + sysid + " AND srcid=" + srcid); + (xtr.GetAttribute("sha1") != null ? " AND sha1='" + xtr.GetAttribute("sha1").ToLowerInvariant().Trim() + "'" : ""); using (SqliteCommand sslc = new SqliteCommand(query, dbc)) {