forked from akanyan/STARTLINER
feat: refresh+start button
This commit is contained in:
@ -49,7 +49,7 @@ pub async fn start_check(state: State<'_, Mutex<AppData>>) -> Result<Vec<StartCh
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn startline(app: AppHandle) -> Result<(), String> {
|
||||
pub async fn startline(app: AppHandle, refresh: bool) -> Result<(), String> {
|
||||
log::debug!("invoke: startline");
|
||||
|
||||
let state = app.state::<Mutex<AppData>>();
|
||||
@ -61,7 +61,7 @@ pub async fn startline(app: AppHandle) -> Result<(), String> {
|
||||
}
|
||||
if let Some(p) = &mut appd.profile {
|
||||
log::debug!("{}", hash);
|
||||
p.line_up(hash, app.clone()).await
|
||||
p.line_up(hash, refresh, app.clone()).await
|
||||
.map_err(|e| format!("Lineup failed:\n{}", e))?;
|
||||
p.start(app.clone()).await
|
||||
.map_err(|e| format!("Startup failed:\n{}", e))?;
|
||||
|
@ -160,7 +160,7 @@ pub async fn run(_args: Vec<String>) {
|
||||
apph.exit(1);
|
||||
}
|
||||
}
|
||||
if let Err(e) = cmd::startline(apph.clone()).await {
|
||||
if let Err(e) = cmd::startline(apph.clone(), false).await {
|
||||
log::error!("Unable to launch: {}", e);
|
||||
apph.exit(1);
|
||||
}
|
||||
|
@ -151,13 +151,13 @@ impl Profile {
|
||||
self.data.sgt = source.sgt;
|
||||
// }
|
||||
}
|
||||
pub async fn line_up(&self, pkg_hash: String, _app: AppHandle) -> Result<()> {
|
||||
pub async fn line_up(&self, pkg_hash: String, refresh: bool, _app: AppHandle) -> Result<()> {
|
||||
let info = match &self.data.display {
|
||||
None => None,
|
||||
Some(display) => display.line_up()?
|
||||
};
|
||||
|
||||
let res = self.line_up_the_rest(pkg_hash).await;
|
||||
let res = self.line_up_the_rest(pkg_hash, refresh).await;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
if let Some(info) = info {
|
||||
@ -171,7 +171,7 @@ impl Profile {
|
||||
|
||||
res
|
||||
}
|
||||
async fn line_up_the_rest(&self, pkg_hash: String) -> Result<()> {
|
||||
async fn line_up_the_rest(&self, pkg_hash: String, refresh: bool) -> Result<()> {
|
||||
if !self.data_dir().exists() {
|
||||
tokio::fs::create_dir(self.data_dir()).await?;
|
||||
}
|
||||
@ -180,7 +180,7 @@ impl Profile {
|
||||
|
||||
util::clean_up_opts(self.data_dir().join("option"))?;
|
||||
|
||||
let hash_check = Self::hash_check(&hash_path, &pkg_hash).await?;
|
||||
let hash_check = Self::hash_check(&hash_path, &pkg_hash).await? || refresh;
|
||||
prepare_packages(&self.meta, &self.data.mods, hash_check).await
|
||||
.map_err(|e| anyhow!("package configuration failed:\n{:?}", e))?;
|
||||
let mut ini = self.data.sgt.line_up(&self.meta, self.meta.game).await
|
||||
|
Reference in New Issue
Block a user