从 deb 等系统包安装时,启动器可执行文件位于 /usr/bin,此前一键安装 StarLight 实例的"选择游戏目录"弹窗会默认到这个系统目录,普通用户既 无写权限,也不适合存放游戏数据。 将默认目录计算移入 theseus::default_game_dir_root():Linux 下若可执行 文件位于 /usr、/opt、/snap 等系统路径,回退到用户主目录;便携版与其 他平台仍使用可执行文件所在目录。
This commit is contained in:
1 parent
0f35a5f707
commit
13a56f4200
3 files changed
+32
-6
No files matched your search
@@ -324,12 +324,9 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
/// external game-directory root for the one-click StarLight install flow.
|
||||
#[tauri::command]
|
||||
fn get_launcher_root_dir() -> api::Result<String> {
|
||||
let exe = std::env::current_exe().map_err(|error| {
|
||||
theseus::Error::from(theseus::ErrorKind::FSError(error.to_string()))
|
||||
})?;
|
||||
let dir = exe.parent().ok_or_else(|| {
|
||||
let dir = theseus::default_game_dir_root().ok_or_else(|| {
|
||||
theseus::Error::from(theseus::ErrorKind::FSError(
|
||||
"Launcher executable has no parent directory".to_string(),
|
||||
"Could not determine a default game directory root".to_string(),
|
||||
))
|
||||
})?;
|
||||
Ok(dir.to_string_lossy().into_owned())
|
||||
|
||||
Reference in new issue
Block a user