Skip to content

Commit

Permalink
fix: check prefix path from server
Browse files Browse the repository at this point in the history
Fixes the prefix being created when it already exists.
  • Loading branch information
donovanglover committed Jan 12, 2025
1 parent c4fa79f commit a370483
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ pub fn exec(address: SocketAddrV4, path: &Path, directory: &str) {
return;
}

if !Path::new(wine_prefix).exists() {
request(address, &container_path, wine_prefix, "init").unwrap();
}
request(address, &container_path, wine_prefix, "init").unwrap();

make_desktop_file(file_name, path);

Expand Down
6 changes: 5 additions & 1 deletion src/server/routes/init.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use axum::extract::Json;
use std::{collections::HashMap, process::Command};
use std::{collections::HashMap, path::Path, process::Command};

use crate::{state::Options, util::notify};

/// Create a wine prefix
pub async fn init(Json(options): Json<Options>) -> Result<String, &'static str> {
let envs = Options::vars(&options);

if Path::new(&options.wine_prefix).exists() {
return Ok("Prefix already exists.".to_string());
}

notify("Initializing wine prefix...", None);

Command::new("wineboot").envs(&envs).output().unwrap();
Expand Down

0 comments on commit a370483

Please sign in to comment.