Skip to content

Commit

Permalink
Merge pull request #69 from cloudnautique/main
Browse files Browse the repository at this point in the history
fix - version was not set properly
  • Loading branch information
cloudnautique authored Feb 16, 2024
2 parents f454542 + 1a7b9b8 commit 67bd67b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
12 changes: 3 additions & 9 deletions tauri/src-tauri/src/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@ use std::io::Write;
use std::path::PathBuf;
use std::process::Command;

pub fn start_docker_containers() -> Result<(), String> {
pub fn start_docker_containers(version: &String) -> Result<(), String> {
let home_dir = dirs::home_dir().ok_or("Could not find the home directory.")?;
let rubra_dir = home_dir.join(".rubra");

let cargo_version = env!("CARGO_PKG_VERSION");
let version = if cargo_version == "0.0.0" {
"main".to_string()
} else {
format!("v{}", cargo_version)
};

let status = Command::new("docker-compose")
.args(["pull"])
.current_dir(&rubra_dir)
.env("RUBRA_TAG", version)
.env("RUBRA_TAG", &version)
.status()
.expect("Failed to execute docker-compose");

Expand All @@ -28,6 +21,7 @@ pub fn start_docker_containers() -> Result<(), String> {
let status = Command::new("docker-compose")
.args(["up", "-d"])
.current_dir(&rubra_dir)
.env("RUBRA_TAG", &version)
.status()
.expect("Failed to execute docker-compose");

Expand Down
7 changes: 6 additions & 1 deletion tauri/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct RubraState {
rubra_dir: PathBuf,
llm_file: PathBuf,
llm_process: Option<std::process::Child>,
app_version: String,
}

#[cfg(target_os = "windows")]
Expand Down Expand Up @@ -342,8 +343,9 @@ async fn rubra_event(
event: &str,
state: tauri::State<'_, Arc<Mutex<RubraState>>>,
) -> Result<Vec<(String, String)>, String> {
let version = state.lock().unwrap().app_version.clone();
if event == "start" {
let _ = start_docker_containers();
let _ = start_docker_containers(&version);
let _ = execute_rubra_llamafile(state);
} else if event == "stop" {
let _ = stop_docker_containers();
Expand Down Expand Up @@ -378,6 +380,7 @@ fn main() {
rubra_dir: dirs::home_dir().unwrap().join(".rubra"),
llm_file: dirs::home_dir().unwrap().join(".rubra").join(llamfile_name),
llm_process: None,
app_version: "".to_string(),
}));

tauri::Builder::default()
Expand Down Expand Up @@ -416,6 +419,8 @@ fn main() {
}
Err(e) => eprintln!("Error: {}", e),
}
let app_version = format!("v{}", app.package_info().version.to_string());
state.lock().unwrap().app_version = app_version.clone();
state.lock().unwrap().rubra_dir = home_dir.join(".rubra");
Ok(())
})
Expand Down

0 comments on commit 67bd67b

Please sign in to comment.