mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[RombaSharp] Fix deleting dats
- Only try to remove dats if some exist to remove - Lump all deletes into a single statement
This commit is contained in:
@@ -217,10 +217,10 @@ namespace RombaSharp
|
|||||||
// Verify the filenames
|
// Verify the filenames
|
||||||
Dictionary<string, string> foundDats = GetValidDats(inputs);
|
Dictionary<string, string> foundDats = GetValidDats(inputs);
|
||||||
|
|
||||||
// Create a base output folder
|
// Ensure the output directory is set
|
||||||
if (!Directory.Exists("out"))
|
if (String.IsNullOrWhiteSpace(outdat))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory("out");
|
outdat = "out";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we have the dictionary, we can loop through and output to a new folder for each
|
// Now that we have the dictionary, we can loop through and output to a new folder for each
|
||||||
@@ -231,11 +231,8 @@ namespace RombaSharp
|
|||||||
datFile.Parse(Path.Combine(_dats, foundDats[key]), 0, 0);
|
datFile.Parse(Path.Combine(_dats, foundDats[key]), 0, 0);
|
||||||
|
|
||||||
// Create the new output directory if it doesn't exist
|
// Create the new output directory if it doesn't exist
|
||||||
string outputFolder = Path.Combine("out", Path.GetFileNameWithoutExtension(foundDats[key]));
|
string outputFolder = Path.Combine(outdat, Path.GetFileNameWithoutExtension(foundDats[key]));
|
||||||
if (!Directory.Exists(outputFolder))
|
Utilities.EnsureOutputDirectory(outputFolder, create: true);
|
||||||
{
|
|
||||||
Directory.CreateDirectory(outputFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all online depots
|
// Get all online depots
|
||||||
List<string> onlineDepots = _depots.Where(d => d.Value.Item2).Select(d => d.Key).ToList();
|
List<string> onlineDepots = _depots.Where(d => d.Value.Item2).Select(d => d.Key).ToList();
|
||||||
@@ -776,17 +773,23 @@ namespace RombaSharp
|
|||||||
watch.Stop();
|
watch.Stop();
|
||||||
|
|
||||||
// Now loop through and remove all references to old Dats
|
// Now loop through and remove all references to old Dats
|
||||||
|
if (unneeded.Count > 0)
|
||||||
|
{
|
||||||
watch.Start("Removing unmatched DAT information");
|
watch.Start("Removing unmatched DAT information");
|
||||||
|
|
||||||
|
query = "DELETE FROM dat WHERE";
|
||||||
foreach (string dathash in unneeded)
|
foreach (string dathash in unneeded)
|
||||||
{
|
{
|
||||||
query = "DELETE FROM dat WHERE hash=\"" + dathash + "\"";
|
query += " OR hash=\"" + dathash + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query.Replace("WHERE OR", "WHERE");
|
||||||
slc = new SqliteCommand(query, dbc);
|
slc = new SqliteCommand(query, dbc);
|
||||||
slc.ExecuteNonQuery();
|
slc.ExecuteNonQuery();
|
||||||
slc.Dispose();
|
slc.Dispose();
|
||||||
}
|
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
dbc.Dispose();
|
dbc.Dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user