mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix merging order and bump version number
This commit is contained in:
@@ -275,7 +275,7 @@ JOIN checksums
|
|||||||
(_systems != "" && _sources != "" ? " AND" : "") +
|
(_systems != "" && _sources != "" ? " AND" : "") +
|
||||||
(_systems != "" ? " systems.id in (" + _systems + ")" : "") +
|
(_systems != "" ? " systems.id in (" + _systems + ")" : "") +
|
||||||
"\nORDER BY " +
|
"\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");
|
: "systems.id, sources.id, games.name, files.name");
|
||||||
|
|
||||||
using (SQLiteConnection dbc = new SQLiteConnection(_connectionString))
|
using (SQLiteConnection dbc = new SQLiteConnection(_connectionString))
|
||||||
@@ -314,35 +314,41 @@ JOIN checksums
|
|||||||
|
|
||||||
if (merged)
|
if (merged)
|
||||||
{
|
{
|
||||||
// Check if the rom is a duplicate
|
// If it's the first rom in the list, don't touch it
|
||||||
RomData last = (roms.Count == 0 ? new RomData() : roms[roms.Count - 1]);
|
if (roms.Count != 0)
|
||||||
bool shouldcont = false;
|
|
||||||
if (temp.Type == "rom" && last.Type == "rom")
|
|
||||||
{
|
{
|
||||||
shouldcont = ((temp.Size != -1 && temp.Size == last.Size) && (
|
// Check if the rom is a duplicate
|
||||||
(temp.CRC != "" && last.CRC != "" && temp.CRC == last.CRC) ||
|
RomData last = roms[roms.Count - 1];
|
||||||
(temp.MD5 != "" && last.MD5 != "" && temp.MD5 == last.MD5) ||
|
|
||||||
(temp.SHA1 != "" && last.SHA1 != "" && temp.SHA1 == last.SHA1)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (temp.Type == "disk" && last.Type == "disk")
|
|
||||||
{
|
|
||||||
shouldcont = ((temp.MD5 != "" && last.MD5 != "" && temp.MD5 == last.MD5) ||
|
|
||||||
(temp.SHA1 != "" && last.SHA1 != "" && temp.SHA1 == last.SHA1)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it's a duplicate, skip adding it to the output but add any missing information
|
bool shouldcont = false;
|
||||||
if (shouldcont)
|
if (temp.Type == "rom" && last.Type == "rom")
|
||||||
{
|
{
|
||||||
last.CRC = (last.CRC == "" && temp.CRC != "" ? temp.CRC : last.CRC);
|
shouldcont = ((temp.Size != -1 && temp.Size == last.Size) && (
|
||||||
last.MD5 = (last.MD5 == "" && temp.MD5 != "" ? temp.MD5 : last.MD5);
|
(temp.CRC != "" && last.CRC != "" && temp.CRC == last.CRC) ||
|
||||||
last.SHA1 = (last.SHA1 == "" && temp.SHA1 != "" ? temp.SHA1 : last.SHA1);
|
(temp.MD5 != "" && last.MD5 != "" && temp.MD5 == last.MD5) ||
|
||||||
roms.RemoveAt(roms.Count - 1);
|
(temp.SHA1 != "" && last.SHA1 != "" && temp.SHA1 == last.SHA1)
|
||||||
roms.Insert(roms.Count - 1, last);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (temp.Type == "disk" && last.Type == "disk")
|
||||||
|
{
|
||||||
|
shouldcont = ((temp.MD5 != "" && last.MD5 != "" && temp.MD5 == last.MD5) ||
|
||||||
|
(temp.SHA1 != "" && last.SHA1 != "" && temp.SHA1 == last.SHA1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
// If it's a duplicate, skip adding it to the output but add any missing information
|
||||||
|
if (shouldcont)
|
||||||
|
{
|
||||||
|
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, last);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the game associated if it's still valid and we allow renames
|
// Rename the game associated if it's still valid and we allow renames
|
||||||
@@ -361,22 +367,25 @@ JOIN checksums
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we're in a merged mode, resort by the correct parameters
|
// If we're in a merged mode, resort by the correct parameters
|
||||||
roms.Sort(delegate (RomData x, RomData y)
|
if (merged)
|
||||||
{
|
{
|
||||||
if (x.SystemID == y.SystemID)
|
roms.Sort(delegate (RomData x, RomData y)
|
||||||
{
|
{
|
||||||
if (x.SourceID == y.SourceID)
|
if (x.SystemID == y.SystemID)
|
||||||
{
|
{
|
||||||
if (x.Game == y.Game)
|
if (x.SourceID == y.SourceID)
|
||||||
{
|
{
|
||||||
return String.Compare(x.Name, y.Name);
|
if (x.Game == y.Game)
|
||||||
|
{
|
||||||
|
return String.Compare(x.Name, y.Name);
|
||||||
|
}
|
||||||
|
return String.Compare(x.Game, y.Game);
|
||||||
}
|
}
|
||||||
return String.Compare(x.Game, y.Game);
|
return (_norename ? String.Compare(x.Game, y.Game) : x.SourceID - y.SourceID);
|
||||||
}
|
}
|
||||||
return (_norename ? String.Compare(x.Game, y.Game) : x.SourceID - y.SourceID);
|
return (_norename ? String.Compare(x.Game, y.Game) : x.SystemID - y.SystemID);
|
||||||
}
|
});
|
||||||
return (_norename ? String.Compare(x.Game, y.Game) : x.SystemID - y.SystemID);
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// Now check rename within games
|
// Now check rename within games
|
||||||
string lastname = "", lastgame = "";
|
string lastname = "", lastgame = "";
|
||||||
|
|||||||
@@ -333,9 +333,9 @@ namespace WoD
|
|||||||
child.Attributes["name"].Value,
|
child.Attributes["name"].Value,
|
||||||
date,
|
date,
|
||||||
(child.Attributes["size"] != null ? Int32.Parse(child.Attributes["size"].Value) : -1),
|
(child.Attributes["size"] != null ? Int32.Parse(child.Attributes["size"].Value) : -1),
|
||||||
(child.Attributes["crc"] != null ? child.Attributes["crc"].Value.ToLowerInvariant() : ""),
|
(child.Attributes["crc"] != null ? child.Attributes["crc"].Value.ToLowerInvariant().Trim() : ""),
|
||||||
(child.Attributes["md5"] != null ? child.Attributes["md5"].Value.ToLowerInvariant() : ""),
|
(child.Attributes["md5"] != null ? child.Attributes["md5"].Value.ToLowerInvariant().Trim() : ""),
|
||||||
(child.Attributes["sha1"] != null ? child.Attributes["sha1"].Value.ToLowerInvariant() : "")
|
(child.Attributes["sha1"] != null ? child.Attributes["sha1"].Value.ToLowerInvariant().Trim() : "")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// If we find the signs of a software list, traverse the children
|
// If we find the signs of a software list, traverse the children
|
||||||
@@ -357,9 +357,9 @@ namespace WoD
|
|||||||
data.Attributes["name"].Value,
|
data.Attributes["name"].Value,
|
||||||
date,
|
date,
|
||||||
(data.Attributes["size"] != null ? Int32.Parse(data.Attributes["size"].Value) : -1),
|
(data.Attributes["size"] != null ? Int32.Parse(data.Attributes["size"].Value) : -1),
|
||||||
(data.Attributes["crc"] != null ? data.Attributes["crc"].Value.ToLowerInvariant() : ""),
|
(data.Attributes["crc"] != null ? data.Attributes["crc"].Value.ToLowerInvariant().Trim() : ""),
|
||||||
(data.Attributes["md5"] != null ? data.Attributes["md5"].Value.ToLowerInvariant() : ""),
|
(data.Attributes["md5"] != null ? data.Attributes["md5"].Value.ToLowerInvariant().Trim() : ""),
|
||||||
(data.Attributes["sha1"] != null ? data.Attributes["sha1"].Value.ToLowerInvariant() : "")
|
(data.Attributes["sha1"] != null ? data.Attributes["sha1"].Value.ToLowerInvariant().Trim() : "")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace WoD
|
|||||||
{
|
{
|
||||||
private static string _dbName = "DATabase.sqlite";
|
private static string _dbName = "DATabase.sqlite";
|
||||||
private static string _connectionString = "Data Source=" + _dbName + ";Version = 3;";
|
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 =
|
private static string _header =
|
||||||
@"+-----------------------------------------------------------------------------+
|
@"+-----------------------------------------------------------------------------+
|
||||||
| DATabase " + _version + @" |
|
| DATabase " + _version + @" |
|
||||||
|
|||||||
Reference in New Issue
Block a user