在发现文件系统实现出错时提示用户 (#1040)
* fix: The implementation of 'Files.isWritable' is incorrect * Report Samba problems to users * Rollback FileUtils
This commit is contained in:
@@ -21,6 +21,7 @@ import javafx.application.Application;
|
|||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import org.jackhuang.hmcl.setting.ConfigHolder;
|
import org.jackhuang.hmcl.setting.ConfigHolder;
|
||||||
|
import org.jackhuang.hmcl.setting.SambaException;
|
||||||
import org.jackhuang.hmcl.task.Schedulers;
|
import org.jackhuang.hmcl.task.Schedulers;
|
||||||
import org.jackhuang.hmcl.task.AsyncTaskExecutor;
|
import org.jackhuang.hmcl.task.AsyncTaskExecutor;
|
||||||
import org.jackhuang.hmcl.ui.AwtUtils;
|
import org.jackhuang.hmcl.ui.AwtUtils;
|
||||||
@@ -62,6 +63,8 @@ public final class Launcher extends Application {
|
|||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
ConfigHolder.init();
|
ConfigHolder.init();
|
||||||
|
} catch (SambaException ignored) {
|
||||||
|
Main.showWarningAndContinue(i18n("fatal.samba"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.log(Level.SEVERE, "Failed to load config", e);
|
LOG.log(Level.SEVERE, "Failed to load config", e);
|
||||||
Main.showErrorAndExit(i18n("fatal.config_loading_failure", Paths.get("").toAbsolutePath().normalize()));
|
Main.showErrorAndExit(i18n("fatal.config_loading_failure", Paths.get("").toAbsolutePath().normalize()));
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ import org.jackhuang.hmcl.util.io.FileUtils;
|
|||||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.*;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@@ -37,7 +35,8 @@ import static org.jackhuang.hmcl.util.Logging.LOG;
|
|||||||
|
|
||||||
public final class ConfigHolder {
|
public final class ConfigHolder {
|
||||||
|
|
||||||
private ConfigHolder() {}
|
private ConfigHolder() {
|
||||||
|
}
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "hmcl.json";
|
public static final String CONFIG_FILENAME = "hmcl.json";
|
||||||
public static final String CONFIG_FILENAME_LINUX = ".hmcl.json";
|
public static final String CONFIG_FILENAME_LINUX = ".hmcl.json";
|
||||||
@@ -97,9 +96,16 @@ public final class ConfigHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Files.isWritable(configLocation)) {
|
if (!Files.isWritable(configLocation)) {
|
||||||
// the config cannot be saved
|
if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS
|
||||||
// throw up the error now to prevent further data loss
|
&& configLocation.getFileSystem() == FileSystems.getDefault()
|
||||||
throw new IOException("Config at " + configLocation + " is not writable");
|
&& configLocation.toFile().canWrite()) {
|
||||||
|
// There are some serious problems with the implementation of Samba or OpenJDK
|
||||||
|
throw new SambaException();
|
||||||
|
} else {
|
||||||
|
// the config cannot be saved
|
||||||
|
// throw up the error now to prevent further data loss
|
||||||
|
throw new IOException("Config at " + configLocation + " is not writable");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.jackhuang.hmcl.setting;
|
||||||
|
|
||||||
|
public final class SambaException extends RuntimeException {
|
||||||
|
public SambaException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SambaException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SambaException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SambaException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -306,6 +306,7 @@ fatal.missing_dst_root_ca_x3=The DST Root CA X3 certificate is missing on the cu
|
|||||||
fatal.config_loading_failure=The configuration is not accessible.\nPlease ensure Hello Minecraft! Launcher has read and write access to "%s" and the files in it.
|
fatal.config_loading_failure=The configuration is not accessible.\nPlease ensure Hello Minecraft! Launcher has read and write access to "%s" and the files in it.
|
||||||
fatal.migration_requires_manual_reboot=The update is complete. Please reopen Hello Minecraft! Launcher.
|
fatal.migration_requires_manual_reboot=The update is complete. Please reopen Hello Minecraft! Launcher.
|
||||||
fatal.apply_update_failure=We're sorry, Hello Minecraft! Launcher couldn't finish the update because something went wrong.\nBut you can still manually finish the update by downloading Hello Minecraft! Launcher from %s.\nPlease consider reporting this issue to us.
|
fatal.apply_update_failure=We're sorry, Hello Minecraft! Launcher couldn't finish the update because something went wrong.\nBut you can still manually finish the update by downloading Hello Minecraft! Launcher from %s.\nPlease consider reporting this issue to us.
|
||||||
|
fatal.samba=If you are trying to run HMCL in a shared folder by Samba, HMCL may not working, please try updating your Java or running HMCL in a local folder.
|
||||||
|
|
||||||
feedback=Feedback
|
feedback=Feedback
|
||||||
feedback.add=Add Feedback
|
feedback.add=Add Feedback
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ fatal.missing_dst_root_ca_x3=目前的 Java 平台缺少 DST Root CA X3 憑證
|
|||||||
fatal.config_loading_failure=Hello Minecraft! Launcher 無法載入設定檔案。\n請確保 Hello Minecraft! Launcher 對 "%s" 目錄及該目錄下的檔案擁有讀寫權限。
|
fatal.config_loading_failure=Hello Minecraft! Launcher 無法載入設定檔案。\n請確保 Hello Minecraft! Launcher 對 "%s" 目錄及該目錄下的檔案擁有讀寫權限。
|
||||||
fatal.migration_requires_manual_reboot=Hello Minecraft! Launcher 即將升級完成,請重新開啟 Hello Minecraft! Launcher。
|
fatal.migration_requires_manual_reboot=Hello Minecraft! Launcher 即將升級完成,請重新開啟 Hello Minecraft! Launcher。
|
||||||
fatal.apply_update_failure=我們很抱歉 Hello Minecraft! Launcher 無法自動完成升級程式,因為出現了一些問題。\n但你依然可以從 %s 處手動下載 Hello Minecraft! Launcher 來完成升級。\n請考慮向我們回報該問題。
|
fatal.apply_update_failure=我們很抱歉 Hello Minecraft! Launcher 無法自動完成升級程式,因為出現了一些問題。\n但你依然可以從 %s 處手動下載 Hello Minecraft! Launcher 來完成升級。\n請考慮向我們回報該問題。
|
||||||
|
fatal.samba=如果您正在通過 Samba 共亯的資料夾中運行 HMCL,HMCL 可能無法正常工作,請嘗試更新您的 Java 或在本地資料夾內運行 HMCL。
|
||||||
|
|
||||||
feedback=回饋
|
feedback=回饋
|
||||||
feedback.add=新增回饋
|
feedback.add=新增回饋
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ fatal.missing_dst_root_ca_x3=当前 Java 平台缺少 DST Root CA X3 证书。\n
|
|||||||
fatal.config_loading_failure=Hello Minecraft! Launcher 无法加载配置文件。\n请确保 Hello Minecraft! Launcher 对 "%s" 目录及该目录下的文件拥有读写权限。
|
fatal.config_loading_failure=Hello Minecraft! Launcher 无法加载配置文件。\n请确保 Hello Minecraft! Launcher 对 "%s" 目录及该目录下的文件拥有读写权限。
|
||||||
fatal.migration_requires_manual_reboot=Hello Minecraft! Launcher 即将完成升级,请重新打开 Hello Minecraft! Launcher。
|
fatal.migration_requires_manual_reboot=Hello Minecraft! Launcher 即将完成升级,请重新打开 Hello Minecraft! Launcher。
|
||||||
fatal.apply_update_failure=我们很抱歉 Hello Minecraft! Launcher 无法自动完成升级,因为出现了一些问题。\n但你依然可以从 %s 处手动下载 Hello Minecraft! Launcher 来完成升级。\n请考虑向我们反馈该问题。
|
fatal.apply_update_failure=我们很抱歉 Hello Minecraft! Launcher 无法自动完成升级,因为出现了一些问题。\n但你依然可以从 %s 处手动下载 Hello Minecraft! Launcher 来完成升级。\n请考虑向我们反馈该问题。
|
||||||
|
fatal.samba=如果您正在通过 Samba 共享的文件夹中运行 HMCL,HMCL 可能无法正常工作,请尝试更新您的 Java 或在本地文件夹内运行 HMCL。
|
||||||
|
|
||||||
feedback=反馈
|
feedback=反馈
|
||||||
feedback.add=新增反馈
|
feedback.add=新增反馈
|
||||||
|
|||||||
Reference in New Issue
Block a user