fix: SCLoggerHelper

This commit is contained in:
xkeyC 2024-06-16 12:11:19 +08:00
parent 2e69068209
commit c7d70084d8

View File

@ -32,8 +32,9 @@ class SCLoggerHelper {
static Future<List?> getLauncherLogList() async { static Future<List?> getLauncherLogList() async {
if (!Platform.isWindows) return []; if (!Platform.isWindows) return [];
try {
final jsonLogPath = await getLogFilePath(); final jsonLogPath = await getLogFilePath();
if (jsonLogPath == null) return null; if (jsonLogPath == null) throw "no file path";
var jsonString = utf8.decode(await File(jsonLogPath).readAsBytes()); var jsonString = utf8.decode(await File(jsonLogPath).readAsBytes());
if (jsonString.endsWith("\n")) { if (jsonString.endsWith("\n")) {
jsonString = jsonString.substring(0, jsonString.length - 3); jsonString = jsonString.substring(0, jsonString.length - 3);
@ -45,6 +46,10 @@ class SCLoggerHelper {
jsonString = jsonString.substring(0, jsonString.length - 3); jsonString = jsonString.substring(0, jsonString.length - 3);
} }
return json.decode("[$jsonString]"); return json.decode("[$jsonString]");
} catch (e) {
dPrint(e);
return [];
}
} }
static Future<List<String>> getGameInstallPath(List listData, static Future<List<String>> getGameInstallPath(List listData,
@ -94,11 +99,6 @@ class SCLoggerHelper {
await checkAndAddPath(installPath, checkExists); await checkAndAddPath(installPath, checkExists);
} }
} }
}
} catch (e) {
dPrint(e);
if (scInstallPaths.isEmpty) rethrow;
}
if (scInstallPaths.isNotEmpty) { if (scInstallPaths.isNotEmpty) {
// //
@ -114,6 +114,11 @@ class SCLoggerHelper {
} }
} }
} }
}
} catch (e) {
dPrint(e);
if (scInstallPaths.isEmpty) rethrow;
}
return scInstallPaths; return scInstallPaths;
} }