UOM // Add capabilities of handling empty data files on load.

This commit is contained in:
ShikiSuen 2022-09-08 21:44:28 +08:00
parent e01ddb47d8
commit 9766bea1a0
1 changed files with 1 additions and 0 deletions

View File

@ -194,6 +194,7 @@ extension vChewing.LMUserOverride {
let decoder = JSONDecoder()
do {
let data = try Data(contentsOf: fileURL, options: .mappedIfSafe)
if ["", "{}"].contains(String(data: data, encoding: .utf8)) { return }
guard let jsonResult = try? decoder.decode([String: KeyObservationPair].self, from: data) else {
IME.prtDebugIntel("UOM Error: Read file content type invalid, abort loading.")
return