Fix: Attempt at Windows-Installer without TPU

This commit is contained in:
Youwes09
2026-04-22 22:25:24 -05:00
parent 2eb8a7662e
commit 6634ad56d2
2 changed files with 45 additions and 23 deletions
+1 -7
View File
@@ -45,14 +45,8 @@ In-Progress:
- Fix Tracking Login - Fix Tracking Login
- Pasting OAuth URL is not User-Friendly, Look for Alternatives - Pasting OAuth URL is not User-Friendly, Look for Alternatives
- Fix Home Layout & Scaling
- Layout constrains UI, Hero-Card Disappears?
- Home Layout itself is currently off.
- Add Updates Substitute, Derived from One Source + Genre Tags (Check Library for Tags)
- ActivityHeatmap needs Proper Constraints for Month Namescd
- MacOS Fixes - MacOS Fixes
- Revamp Server-State Check (MacOS does not pick up) - Revamp Server-State Check (MacOS does not pick up) (TESTING)
- Check Moku Sidebar Icon (Looks ugly on MacOS) - Check Moku Sidebar Icon (Looks ugly on MacOS)
- Icon appears as a Square - Icon appears as a Square
- Icon appears to have Green Underglow? - Icon appears to have Green Underglow?
+44 -16
View File
@@ -634,30 +634,58 @@ async fn list_releases() -> Result<Vec<ReleaseInfo>, String> {
#[tauri::command] #[tauri::command]
#[allow(unused_variables)] #[allow(unused_variables)]
async fn download_and_install_update(app: tauri::AppHandle) -> Result<(), String> { async fn download_and_install_update(app: tauri::AppHandle, tag: String) -> Result<(), String> {
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
return Err("Native install is Windows-only; open the GitHub release page instead.".into()); return Err("Native install is Windows-only; open the GitHub release page instead.".into());
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
{ {
use tauri_plugin_updater::UpdaterExt; use tauri_plugin_http::reqwest;
use std::io::Write;
let updater = app.updater().map_err(|e| e.to_string())?; let client = reqwest::Client::builder()
let update = updater.check().await.map_err(|e| e.to_string())?; .user_agent("Moku")
.build()
.map_err(|e| e.to_string())?;
let Some(update) = update else { // Fetch the specific release by tag to get its asset list.
return Err("No update available.".into()); let url = format!("https://api.github.com/repos/Youwes09/Moku/releases/tags/{}", tag);
}; let resp = client.get(&url).send().await.map_err(|e| e.to_string())?;
if !resp.status().is_success() {
return Err(format!("GitHub API returned {} for tag {}", resp.status(), tag));
}
let app_clone = app.clone(); #[derive(serde::Deserialize)]
update struct Asset { name: String, browser_download_url: String, size: u64 }
.download_and_install( #[derive(serde::Deserialize)]
move |downloaded, total| { struct Release { assets: Vec<Asset> }
let _ = app_clone.emit("update-progress", UpdateProgress { downloaded: downloaded as u64, total });
}, let release: Release = resp.json().await.map_err(|e| e.to_string())?;
|| {},
) let asset = release.assets
.await .into_iter()
.find(|a| a.name.ends_with("_x64-setup.exe"))
.ok_or_else(|| format!("No x64-setup.exe asset found in release {}", tag))?;
// Stream download with progress events.
let total = if asset.size > 0 { Some(asset.size) } else { None };
let mut resp = client.get(&asset.browser_download_url).send().await.map_err(|e| e.to_string())?;
let tmp_path = std::env::temp_dir().join(&asset.name);
let mut file = std::fs::File::create(&tmp_path).map_err(|e| e.to_string())?;
let mut downloaded: u64 = 0;
while let Some(chunk) = resp.chunk().await.map_err(|e| e.to_string())? {
file.write_all(&chunk).map_err(|e| e.to_string())?;
downloaded += chunk.len() as u64;
let _ = app.emit("update-progress", UpdateProgress { downloaded, total });
}
drop(file);
// Launch the NSIS installer — it handles closing/replacing the running app.
std::process::Command::new("cmd")
.args(["/C", "start", "", &tmp_path.to_string_lossy()])
.spawn()
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
Ok(()) Ok(())