mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Try-catch is the best solution, since people might be using a blank dats.sqlite instead of the prepopulated one
This commit is contained in:
@@ -128,7 +128,7 @@ COMMIT;";
|
||||
string source = GetSourceFromFileName(Path.GetFileName(file));
|
||||
int sourceid = 0;
|
||||
|
||||
Dictionary<string, int> sources = new Dictionary<string, int>();
|
||||
SortedDictionary<string, int> sources = new SortedDictionary<string, int>();
|
||||
sources.Add("default", 0);
|
||||
query = "SELECT name, id FROM source";
|
||||
using (SqliteCommand sslc = new SqliteCommand(query, dbc))
|
||||
@@ -207,15 +207,29 @@ COMMIT;";
|
||||
}
|
||||
// Otherwise, get the ID
|
||||
else if (source != "" && sourceid == 0 && sources.ContainsKey(source))
|
||||
{
|
||||
try
|
||||
{
|
||||
sourceid = sources[source.ToLowerInvariant()];
|
||||
}
|
||||
catch
|
||||
{
|
||||
sourceid = 0;
|
||||
}
|
||||
}
|
||||
// Otherwise, we should already have an ID
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
sourceid = sources[source.ToLowerInvariant()];
|
||||
}
|
||||
catch
|
||||
{
|
||||
sourceid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the source and system link to the database
|
||||
string uquery = @"INSERT OR IGNORE INTO datsdata (id, key, value)
|
||||
|
||||
Reference in New Issue
Block a user