Fix merging order and bump version number

This commit is contained in:
Matt Nadareski
2016-03-28 14:28:51 -07:00
parent e2cb6acd41
commit 9fede1a207
3 changed files with 53 additions and 44 deletions

View File

@@ -275,7 +275,7 @@ JOIN checksums
(_systems != "" && _sources != "" ? " AND" : "") +
(_systems != "" ? " systems.id in (" + _systems + ")" : "") +
"\nORDER BY " +
(merged ? "checksums.size, checksums.crc, checksums.md5, checksums.sha1"
(merged ? "checksums.size, checksums.crc, systems.id, sources.id, checksums.md5, checksums.sha1"
: "systems.id, sources.id, games.name, files.name");
using (SQLiteConnection dbc = new SQLiteConnection(_connectionString))
@@ -313,9 +313,13 @@ JOIN checksums
};
if (merged)
{
// If it's the first rom in the list, don't touch it
if (roms.Count != 0)
{
// Check if the rom is a duplicate
RomData last = (roms.Count == 0 ? new RomData() : roms[roms.Count - 1]);
RomData last = roms[roms.Count - 1];
bool shouldcont = false;
if (temp.Type == "rom" && last.Type == "rom")
{
@@ -339,11 +343,13 @@ JOIN checksums
last.CRC = (last.CRC == "" && temp.CRC != "" ? temp.CRC : last.CRC);
last.MD5 = (last.MD5 == "" && temp.MD5 != "" ? temp.MD5 : last.MD5);
last.SHA1 = (last.SHA1 == "" && temp.SHA1 != "" ? temp.SHA1 : last.SHA1);
roms.RemoveAt(roms.Count - 1);
roms.Insert(roms.Count - 1, last);
roms.Insert(roms.Count, last);
continue;
}
}
// Rename the game associated if it's still valid and we allow renames
if (!_norename)
@@ -361,6 +367,8 @@ JOIN checksums
}
// If we're in a merged mode, resort by the correct parameters
if (merged)
{
roms.Sort(delegate (RomData x, RomData y)
{
if (x.SystemID == y.SystemID)
@@ -377,6 +385,7 @@ JOIN checksums
}
return (_norename ? String.Compare(x.Game, y.Game) : x.SystemID - y.SystemID);
});
}
// Now check rename within games
string lastname = "", lastgame = "";

View File

@@ -333,9 +333,9 @@ namespace WoD
child.Attributes["name"].Value,
date,
(child.Attributes["size"] != null ? Int32.Parse(child.Attributes["size"].Value) : -1),
(child.Attributes["crc"] != null ? child.Attributes["crc"].Value.ToLowerInvariant() : ""),
(child.Attributes["md5"] != null ? child.Attributes["md5"].Value.ToLowerInvariant() : ""),
(child.Attributes["sha1"] != null ? child.Attributes["sha1"].Value.ToLowerInvariant() : "")
(child.Attributes["crc"] != null ? child.Attributes["crc"].Value.ToLowerInvariant().Trim() : ""),
(child.Attributes["md5"] != null ? child.Attributes["md5"].Value.ToLowerInvariant().Trim() : ""),
(child.Attributes["sha1"] != null ? child.Attributes["sha1"].Value.ToLowerInvariant().Trim() : "")
);
}
// If we find the signs of a software list, traverse the children
@@ -357,9 +357,9 @@ namespace WoD
data.Attributes["name"].Value,
date,
(data.Attributes["size"] != null ? Int32.Parse(data.Attributes["size"].Value) : -1),
(data.Attributes["crc"] != null ? data.Attributes["crc"].Value.ToLowerInvariant() : ""),
(data.Attributes["md5"] != null ? data.Attributes["md5"].Value.ToLowerInvariant() : ""),
(data.Attributes["sha1"] != null ? data.Attributes["sha1"].Value.ToLowerInvariant() : "")
(data.Attributes["crc"] != null ? data.Attributes["crc"].Value.ToLowerInvariant().Trim() : ""),
(data.Attributes["md5"] != null ? data.Attributes["md5"].Value.ToLowerInvariant().Trim() : ""),
(data.Attributes["sha1"] != null ? data.Attributes["sha1"].Value.ToLowerInvariant().Trim() : "")
);
}
}

View File

@@ -11,7 +11,7 @@ namespace WoD
{
private static string _dbName = "DATabase.sqlite";
private static string _connectionString = "Data Source=" + _dbName + ";Version = 3;";
private static string _version = "0.0.6.0";
private static string _version = "0.0.6.1";
private static string _header =
@"+-----------------------------------------------------------------------------+
| DATabase " + _version + @" |