fix: YearlyReportData error

This commit is contained in:
xkeyC 2025-12-18 11:14:22 +08:00
parent 00e8b0c303
commit 4b2ac25c1f

View File

@ -285,11 +285,11 @@ class YearlyReportAnalyzer {
static Future<_LogFileStats> _analyzeLogFile(File logFile, int targetYear) async { static Future<_LogFileStats> _analyzeLogFile(File logFile, int targetYear) async {
final stats = _LogFileStats(); final stats = _LogFileStats();
try {
if (!(await logFile.exists())) { if (!(await logFile.exists())) {
return stats; return stats;
} }
try {
final content = utf8.decode(await logFile.readAsBytes(), allowMalformed: true); final content = utf8.decode(await logFile.readAsBytes(), allowMalformed: true);
final lines = content.split('\n'); final lines = content.split('\n');
@ -472,6 +472,7 @@ class YearlyReportAnalyzer {
// //
for (final installPath in gameInstallPaths) { for (final installPath in gameInstallPaths) {
try {
final installDir = Directory(installPath); final installDir = Directory(installPath);
// //
@ -483,11 +484,16 @@ class YearlyReportAnalyzer {
final logBackupsDir = Directory('$installPath/logbackups'); final logBackupsDir = Directory('$installPath/logbackups');
// Game.log // Game.log
try {
if (await gameLogFile.exists()) { if (await gameLogFile.exists()) {
allLogFiles.add(gameLogFile); allLogFiles.add(gameLogFile);
} }
} catch (_) {
//
}
// //
try {
if (await logBackupsDir.exists()) { if (await logBackupsDir.exists()) {
await for (final entity in logBackupsDir.list()) { await for (final entity in logBackupsDir.list()) {
if (entity is File && entity.path.endsWith('.log')) { if (entity is File && entity.path.endsWith('.log')) {
@ -495,10 +501,24 @@ class YearlyReportAnalyzer {
} }
} }
} }
} catch (_) {
//
}
} catch (_) {
//
continue;
}
} }
// // 使
final futures = allLogFiles.map((file) => _analyzeLogFile(file, targetYear)); final futures = allLogFiles.map((file) async {
try {
return await _analyzeLogFile(file, targetYear);
} catch (_) {
//
return _LogFileStats();
}
});
final allStatsRaw = await Future.wait(futures); final allStatsRaw = await Future.wait(futures);
// : 使 uniqueKey ( + ) // : 使 uniqueKey ( + )