From 05d9c252cf01ca05e404d32c7adee4cde04af697 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 4 May 2022 11:16:31 +0800 Subject: [PATCH] LMs // Stop letting consolidation process block loading. --- Source/Modules/FileHandlers/LMConsolidator.swift | 4 ++-- Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift | 8 ++------ Source/Modules/LangModelRelated/SubLMs/lmCore.swift | 8 ++------ Source/Modules/LangModelRelated/SubLMs/lmLite.swift | 8 ++------ .../Modules/LangModelRelated/SubLMs/lmReplacements.swift | 8 ++------ 5 files changed, 10 insertions(+), 26 deletions(-) diff --git a/Source/Modules/FileHandlers/LMConsolidator.swift b/Source/Modules/FileHandlers/LMConsolidator.swift index 6a135716..2d558560 100644 --- a/Source/Modules/FileHandlers/LMConsolidator.swift +++ b/Source/Modules/FileHandlers/LMConsolidator.swift @@ -52,7 +52,7 @@ extension vChewing { return false } - public static func fixEOF(path: String) -> Bool { + @discardableResult public static func fixEOF(path: String) -> Bool { let urlPath = URL(fileURLWithPath: path) if FileManager.default.fileExists(atPath: path) { var strIncoming = "" @@ -75,7 +75,7 @@ extension vChewing { return false } - public static func consolidate(path: String, pragma shouldCheckPragma: Bool) -> Bool { + @discardableResult public static func consolidate(path: String, pragma shouldCheckPragma: Bool) -> Bool { var pragmaResult = false if shouldCheckPragma { pragmaResult = checkPragma(path: path) diff --git a/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift b/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift index 6a705ed0..2d8a5ba9 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift @@ -49,12 +49,8 @@ extension vChewing { return false } - if !LMConsolidator.fixEOF(path: path) { - return false - } - if !LMConsolidator.consolidate(path: path, pragma: true) { - return false - } + LMConsolidator.fixEOF(path: path) + LMConsolidator.consolidate(path: path, pragma: true) do { theData = try String(contentsOfFile: path, encoding: .utf8) diff --git a/Source/Modules/LangModelRelated/SubLMs/lmCore.swift b/Source/Modules/LangModelRelated/SubLMs/lmCore.swift index 03115e76..116881f7 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmCore.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmCore.swift @@ -61,12 +61,8 @@ extension vChewing { } if allowConsolidation { - if !LMConsolidator.fixEOF(path: path) { - return false - } - if !LMConsolidator.consolidate(path: path, pragma: true) { - return false - } + LMConsolidator.fixEOF(path: path) + LMConsolidator.consolidate(path: path, pragma: true) } do { diff --git a/Source/Modules/LangModelRelated/SubLMs/lmLite.swift b/Source/Modules/LangModelRelated/SubLMs/lmLite.swift index 755cfd9d..2ec05cc3 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmLite.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmLite.swift @@ -52,12 +52,8 @@ extension vChewing { } if allowConsolidation { - if !LMConsolidator.fixEOF(path: path) { - return false - } - if !LMConsolidator.consolidate(path: path, pragma: true) { - return false - } + LMConsolidator.fixEOF(path: path) + LMConsolidator.consolidate(path: path, pragma: true) } do { diff --git a/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift b/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift index e14e9e83..2dc3c267 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift @@ -49,12 +49,8 @@ extension vChewing { return false } - if !LMConsolidator.fixEOF(path: path) { - return false - } - if !LMConsolidator.consolidate(path: path, pragma: true) { - return false - } + LMConsolidator.fixEOF(path: path) + LMConsolidator.consolidate(path: path, pragma: true) do { theData = try String(contentsOfFile: path, encoding: .utf8)