Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Dec 16, 2023
1 parent 236afcd commit 67c2db0
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 158 deletions.
229 changes: 109 additions & 120 deletions JL.Core/Dicts/DictUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,29 +589,28 @@ public static async Task LoadDictionaries()
}));
}

else
else if (dict.Contents.Count > 0 && (!dict.Active || useDB))
{
if (dict.Contents.Count > 0 && (!dict.Active || useDB))
dict.Ready = false;
if (useDB && !dbExists)
{
if (useDB && !dbExists)
{
tasks.Add(Task.Run(() =>
{
JmdictDBManager.CreateDB(dict.Name);
JmdictDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}));
}
else
tasks.Add(Task.Run(() =>
{
JmdictDBManager.CreateDB(dict.Name);
JmdictDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}

dictCleared = true;
dict.Ready = true;
}));
}
dict.Ready = true;
else
{
dict.Contents.Clear();
dict.Contents.TrimExcess();
dict.Ready = true;
}

dictCleared = true;
}
}

Expand Down Expand Up @@ -646,30 +645,28 @@ public static async Task LoadDictionaries()
}));
}

else
else if (dict.Contents.Count > 0 && (!dict.Active || useDB))
{
if (dict.Contents.Count > 0 && (!dict.Active || useDB))
dict.Ready = false;
if (useDB && !dbExists)
{
if (useDB && !dbExists)
{
tasks.Add(Task.Run(() =>
{
JmnedictDBManager.CreateDB(dict.Name);
JmnedictDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}));
}
else
tasks.Add(Task.Run(() =>
{
JmnedictDBManager.CreateDB(dict.Name);
JmnedictDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}

dictCleared = true;
dict.Ready = true;
}));
}
else
{
dict.Contents.Clear();
dict.Contents.TrimExcess();
dict.Ready = true;
}

dict.Ready = true;
dictCleared = true;
}
}

Expand Down Expand Up @@ -711,30 +708,26 @@ public static async Task LoadDictionaries()
}));
}

else
else if (dict.Contents.Count > 0 && (!dict.Active || useDB))
{
if (dict.Contents.Count > 0 && (!dict.Active || useDB))
dict.Ready = false;
if (useDB && !dbExists)
{
if (useDB && !dbExists)
{
tasks.Add(Task.Run(() =>
{
KanjidicDBManager.CreateDB(dict.Name);
KanjidicDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}));
}
else
tasks.Add(Task.Run(() =>
{
KanjidicDBManager.CreateDB(dict.Name);
KanjidicDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}

dictCleared = true;
dict.Ready = true;
}));
}
else
{
dict.Contents.Clear();
dict.Contents.TrimExcess();
dict.Ready = true;
}

dict.Ready = true;
}
}

Expand Down Expand Up @@ -837,29 +830,28 @@ public static async Task LoadDictionaries()
}));
}

else
else if (dict.Contents.Count > 0 && (!dict.Active || useDB))
{
if (dict.Contents.Count > 0 && (!dict.Active || useDB))
dict.Ready = false;
if (useDB && !dbExists)
{
if (useDB && !dbExists)
{
tasks.Add(Task.Run(() =>
{
EpwingYomichanDBManager.CreateDB(dict.Name);
EpwingYomichanDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}));
}
else
tasks.Add(Task.Run(() =>
{
EpwingYomichanDBManager.CreateDB(dict.Name);
EpwingYomichanDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}

dictCleared = true;
dict.Ready = true;
}));
}
dict.Ready = true;
else
{
dict.Contents.Clear();
dict.Contents.TrimExcess();
dict.Ready = true;
}

dictCleared = true;
}

break;
Expand Down Expand Up @@ -913,29 +905,28 @@ public static async Task LoadDictionaries()
}));
}

else
else if (dict.Contents.Count > 0 && (!dict.Active || useDB))
{
if (dict.Contents.Count > 0 && (!dict.Active || useDB))
dict.Ready = false;
if (useDB && !dbExists)
{
if (useDB && !dbExists)
{
tasks.Add(Task.Run(() =>
{
YomichanKanjiDBManager.CreateDB(dict.Name);
YomichanKanjiDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}));
}
else
tasks.Add(Task.Run(() =>
{
YomichanKanjiDBManager.CreateDB(dict.Name);
YomichanKanjiDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}

dictCleared = true;
dict.Ready = true;
}));
}
dict.Ready = true;
else
{
dict.Contents.Clear();
dict.Contents.TrimExcess();
dict.Ready = true;
}

dictCleared = true;
}

break;
Expand Down Expand Up @@ -1081,29 +1072,28 @@ dict.Type is DictType.CustomNameDictionary
}));
}

else
else if (dict.Contents.Count > 0 && (!dict.Active || useDB))
{
if (dict.Contents.Count > 0 && (!dict.Active || useDB))
dict.Ready = false;
if (useDB && !dbExists)
{
if (useDB && !dbExists)
{
tasks.Add(Task.Run(() =>
{
EpwingNazekaDBManager.CreateDB(dict.Name);
EpwingNazekaDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}));
}
else
tasks.Add(Task.Run(() =>
{
EpwingNazekaDBManager.CreateDB(dict.Name);
EpwingNazekaDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}

dictCleared = true;
dict.Ready = true;
}));
}
dict.Ready = true;
else
{
dict.Contents.Clear();
dict.Contents.TrimExcess();
dict.Ready = true;
}

dictCleared = true;
}

break;
Expand Down Expand Up @@ -1158,29 +1148,28 @@ dict.Type is DictType.CustomNameDictionary
}));
}

else
else if (dict.Contents.Count > 0 && (!dict.Active || useDB))
{
if (dict.Contents.Count > 0 && (!dict.Active || useDB))
dict.Ready = false;
if (useDB && !dbExists)
{
if (useDB && !dbExists)
{
tasks.Add(Task.Run(() =>
{
YomichanPitchAccentDBManager.CreateDB(dict.Name);
YomichanPitchAccentDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}));
}
else
tasks.Add(Task.Run(() =>
{
YomichanPitchAccentDBManager.CreateDB(dict.Name);
YomichanPitchAccentDBManager.InsertRecordsToDB(dict);
dict.Contents.Clear();
dict.Contents.TrimExcess();
}

dictCleared = true;
dict.Ready = true;
}));
}
dict.Ready = true;
else
{
dict.Contents.Clear();
dict.Contents.TrimExcess();
dict.Ready = true;
}

dictCleared = true;
}

break;
Expand Down
Loading

0 comments on commit 67c2db0

Please sign in to comment.