mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-11 12:56:53 -04:00
Update GameCrashWindow.java
This commit is contained in:
parent
35f191412b
commit
925eebcb25
@ -269,10 +269,17 @@ public class GameCrashWindow extends Stage {
|
|||||||
|
|
||||||
private void exportGameCrashInfo() {
|
private void exportGameCrashInfo() {
|
||||||
Path logFile = Paths.get("minecraft-exported-crash-info-" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH-mm-ss")) + ".zip").toAbsolutePath();
|
Path logFile = Paths.get("minecraft-exported-crash-info-" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH-mm-ss")) + ".zip").toAbsolutePath();
|
||||||
Path crashReportFile = repository.getRunDirectory(version.getId()).toPath().resolve("hmcl-game-crash-report.log");
|
Path crashReportFile;
|
||||||
|
try {
|
||||||
|
crashReportFile = Files.createTempFile("hmcl-game-crash-report-", ".log");
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.warning("Failed to create temporary crash report file, using run directory instead", e);
|
||||||
|
crashReportFile = repository.getRunDirectory(version.getId()).toPath().resolve("hmcl-game-crash-report.log");
|
||||||
|
}
|
||||||
|
|
||||||
|
Path finalCrashReportFile = crashReportFile;
|
||||||
CompletableFuture.supplyAsync(() -> {
|
CompletableFuture.supplyAsync(() -> {
|
||||||
try (BufferedWriter report = Files.newBufferedWriter(crashReportFile, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
try (BufferedWriter report = Files.newBufferedWriter(finalCrashReportFile, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
||||||
report.write("=== HMCL Game Crash Report ===\n");
|
report.write("=== HMCL Game Crash Report ===\n");
|
||||||
report.write("HMCL Version: " + Metadata.VERSION + "\n");
|
report.write("HMCL Version: " + Metadata.VERSION + "\n");
|
||||||
report.write("Current Directory: " + Metadata.CURRENT_DIRECTORY + "\n");
|
report.write("Current Directory: " + Metadata.CURRENT_DIRECTORY + "\n");
|
||||||
@ -376,7 +383,7 @@ public class GameCrashWindow extends Stage {
|
|||||||
LOG.warning("Failed to write crash report file", e);
|
LOG.warning("Failed to write crash report file", e);
|
||||||
}
|
}
|
||||||
return logs.stream().map(Log::getLog).collect(Collectors.joining("\n"));
|
return logs.stream().map(Log::getLog).collect(Collectors.joining("\n"));
|
||||||
}).thenComposeAsync(logs -> LogExporter.exportLogs(logFile, repository, launchOptions.getVersionName(), logs, new CommandBuilder().addAll(managedProcess.getCommands()).toString(), crashReportFile)).handleAsync((result, exception) -> {
|
}).thenComposeAsync(logs -> LogExporter.exportLogs(logFile, repository, launchOptions.getVersionName(), logs, new CommandBuilder().addAll(managedProcess.getCommands()).toString(), finalCrashReportFile)).handleAsync((result, exception) -> {
|
||||||
Alert alert;
|
Alert alert;
|
||||||
|
|
||||||
if (exception == null) {
|
if (exception == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user