Fix mac permissions button
This commit is contained in:
@@ -144,19 +144,34 @@ async fn download(
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
|
||||||
{
|
|
||||||
let executable_path = game_path.join(&name).join(&executable);
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
|
let executable_path = game_path.join(&name).join(&executable);
|
||||||
let mut perms = fs::metadata(&executable_path).unwrap().permissions();
|
let mut perms = fs::metadata(&executable_path).unwrap().permissions();
|
||||||
perms.set_mode(0o755);
|
perms.set_mode(0o755);
|
||||||
fs::set_permissions(executable_path, perms).unwrap();
|
fs::set_permissions(executable_path, perms).unwrap();
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
let _ = Command::new(format!("osascript -e 'do shell script chmod 755 {} with prompt Administrator is required to make Berry Dash v{} executable with administrator privileges'", &executable_path.to_string_lossy(), &name)).spawn();
|
let macos_app_path = &game_path
|
||||||
}
|
.join(&name)
|
||||||
|
.join(&executable)
|
||||||
|
.join("Contents")
|
||||||
|
.join("MacOS")
|
||||||
|
.join(
|
||||||
|
&executable
|
||||||
|
.chars()
|
||||||
|
.take(&executable.chars().count() - 4)
|
||||||
|
.collect::<String>(),
|
||||||
|
);
|
||||||
|
let _ = Command::new("osascript")
|
||||||
|
.arg("-e")
|
||||||
|
.arg(format!(
|
||||||
|
"do shell script \"chmod 755 \\\"{}\\\"\" with prompt \"Administrator is required to make Berry Dash v{} executable\" with administrator privileges",
|
||||||
|
macos_app_path.to_string_lossy(),
|
||||||
|
name
|
||||||
|
))
|
||||||
|
.spawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.emit("download-done", &name).unwrap();
|
app.emit("download-done", &name).unwrap();
|
||||||
@@ -334,6 +349,36 @@ async fn open_folder(app: AppHandle, name: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn fix_mac_permissions(app: AppHandle, name: String, executable: String) {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
let macos_app_path = app
|
||||||
|
.path()
|
||||||
|
.app_local_data_dir()
|
||||||
|
.unwrap()
|
||||||
|
.join("game")
|
||||||
|
.join(&name)
|
||||||
|
.join(&executable)
|
||||||
|
.join("Contents")
|
||||||
|
.join("MacOS")
|
||||||
|
.join(
|
||||||
|
&executable
|
||||||
|
.chars()
|
||||||
|
.take(&executable.chars().count() - 4)
|
||||||
|
.collect::<String>(),
|
||||||
|
);
|
||||||
|
let _ = Command::new("osascript")
|
||||||
|
.arg("-e")
|
||||||
|
.arg(format!(
|
||||||
|
"do shell script \"chmod 755 \\\"{}\\\"\" with prompt \"Administrator is required to make Berry Dash v{} executable\" with administrator privileges",
|
||||||
|
macos_app_path.to_string_lossy(),
|
||||||
|
name
|
||||||
|
))
|
||||||
|
.spawn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
@@ -355,7 +400,8 @@ pub fn run() {
|
|||||||
download_leaderboard,
|
download_leaderboard,
|
||||||
get_keys_config,
|
get_keys_config,
|
||||||
uninstall_version,
|
uninstall_version,
|
||||||
open_folder
|
open_folder,
|
||||||
|
fix_mac_permissions
|
||||||
])
|
])
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
|||||||
20
src/main.tsx
20
src/main.tsx
@@ -466,6 +466,26 @@ function App () {
|
|||||||
>
|
>
|
||||||
Open Folder
|
Open Folder
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
className='button'
|
||||||
|
style={{
|
||||||
|
display: platform() == 'macos' ? 'block' : 'none'
|
||||||
|
}}
|
||||||
|
onClick={async () => {
|
||||||
|
const exe =
|
||||||
|
managingVersion.version.executables[
|
||||||
|
managingVersion.version.platforms.indexOf(
|
||||||
|
platform()
|
||||||
|
)
|
||||||
|
]
|
||||||
|
await invoke('fix_mac_permissions', {
|
||||||
|
name: managingVersion.version.version,
|
||||||
|
executable: exe
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Fix permissions
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user