feat: less bad launches
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 974 B |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 903 B |
Before Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 14 KiB |
BIN
rust/icons/slow.png
Normal file
After Width: | Height: | Size: 23 KiB |
@ -9,18 +9,21 @@ use crate::profile::Profile;
|
||||
use crate::appdata::AppData;
|
||||
use crate::{liner, start};
|
||||
|
||||
use tauri::State;
|
||||
use tauri::{AppHandle, Manager, State};
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn startline(state: State<'_, Mutex<AppData>>) -> Result<(), String> {
|
||||
pub async fn startline(app: AppHandle) -> Result<(), String> {
|
||||
log::debug!("invoke: startline");
|
||||
|
||||
let app_copy = app.clone();
|
||||
let state = app.state::<Mutex<AppData>>();
|
||||
let appd = state.lock().await;
|
||||
|
||||
if let Some(p) = &appd.profile {
|
||||
// TODO if p.needsUpdate
|
||||
liner::line_up(p).await.expect("Line-up failed");
|
||||
start::start(p).map_err(|e| { log::error!("Error launching: {}", e.to_string()); e.to_string() }).map(|_| ())
|
||||
start::start(p, app_copy)
|
||||
.map_err(|e| { log::error!("Error launching: {}", e.to_string()); e.to_string() })
|
||||
//Ok(())
|
||||
} else {
|
||||
Err("No profile".to_owned())
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::Path;
|
||||
use anyhow::{Result, anyhow};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -6,7 +6,7 @@ use tauri::{AppHandle, Emitter};
|
||||
use tokio::fs;
|
||||
use tokio::task::JoinSet;
|
||||
use crate::model::rainy;
|
||||
use crate::pkg::{Package, PkgKey};
|
||||
use crate::pkg::{Package, PkgKey, Remote};
|
||||
use crate::util;
|
||||
use crate::download_handler::DownloadHandler;
|
||||
|
||||
@ -134,12 +134,14 @@ impl PackageStore {
|
||||
pkg: key.to_owned()
|
||||
})?;
|
||||
|
||||
let rmt = pkg.rmt.as_ref() //clone()
|
||||
let rmt = pkg.rmt.as_ref()
|
||||
.ok_or_else(|| anyhow!("Attempted to install a pkg without remote data"))?;
|
||||
|
||||
if install_deps {
|
||||
for dep in &rmt.dependencies {
|
||||
Box::pin(self.install_package(&dep, false, true)).await?;
|
||||
let mut set = HashSet::new();
|
||||
self.resolve_deps(rmt.clone(), &mut set)?;
|
||||
for dep in set {
|
||||
Box::pin(self.install_package(&dep, false, false)).await?;
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,4 +246,18 @@ impl PackageStore {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn resolve_deps(&self, rmt: Remote, set: &mut HashSet<PkgKey>) -> Result<()> {
|
||||
for d in rmt.dependencies {
|
||||
set.insert(d.clone());
|
||||
let subrmt = self.store.get(&d)
|
||||
.ok_or_else(|| anyhow!("Attempted to delete a nonexistent pkg"))?
|
||||
.rmt
|
||||
.clone()
|
||||
.ok_or_else(|| anyhow!("Attempted to resolve deps without fetching"))?;
|
||||
self.resolve_deps(subrmt, set)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,32 @@
|
||||
use anyhow::Result;
|
||||
use tokio::process::Command;
|
||||
use tauri::{AppHandle, Emitter};
|
||||
use crate::profile::Profile;
|
||||
use crate::util;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn start(p: &Profile) -> Result<()> {
|
||||
Command::new(p.wine_runtime.as_ref().unwrap())
|
||||
.env(
|
||||
"SEGATOOLS_CONFIG_PATH",
|
||||
util::profile_dir(&p).join("segatools.ini"),
|
||||
)
|
||||
.env("WINEPREFIX", p.wine_prefix.as_ref().unwrap())
|
||||
.arg(p.exe_dir.join("start.bat"))
|
||||
.spawn()?;
|
||||
pub fn start(p: &Profile, app: AppHandle) -> Result<()> {
|
||||
let p = p.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let rv = Command::new(p.wine_runtime.as_ref().unwrap())
|
||||
.env(
|
||||
"SEGATOOLS_CONFIG_PATH",
|
||||
util::profile_dir(&p).join("segatools.ini"),
|
||||
)
|
||||
.env("WINEPREFIX", p.wine_prefix.as_ref().unwrap())
|
||||
.arg(p.exe_dir.join("start.bat"))
|
||||
.spawn();
|
||||
match rv {
|
||||
Ok(mut child) => {
|
||||
_ = child.wait().await;
|
||||
log::debug!("Fin");
|
||||
},
|
||||
Err(e) => {
|
||||
log::error!("Fail: {}", e);
|
||||
}
|
||||
}
|
||||
_ = app.emit("launch-end", "");
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -72,6 +86,8 @@ pub fn start(p: &Profile) -> Result<()> {
|
||||
set.join_next().await.expect("No spawn").expect("No result");
|
||||
|
||||
log::debug!("Fin");
|
||||
|
||||
app.emit("launch-end", "");
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
@ -42,12 +42,6 @@
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
"icon": ["icons/slow.png"]
|
||||
}
|
||||
}
|
||||
|