9e8f1bbeed
Dashboard / frontend (push) Failing after 0s
Dashboard / api (push) Failing after 0s
Lint PowerShell / powershell-lint (ubuntu-latest) (push) Failing after 1s
Python Lint / Lint Python with Ruff (push) Failing after 1s
ShellCheck / Lint shell scripts (push) Failing after 1s
Matrix Smoke / linux-smoke (push) Failing after 1s
Matrix Smoke / distro: cachyos (push) Failing after 15s
Matrix Smoke / distro: linux-mint-21.3 (push) Failing after 15s
Matrix Smoke / distro: debian-12 (push) Failing after 5m21s
Matrix Smoke / distro: fedora-41 (push) Failing after 4m56s
Matrix Smoke / distro: ubuntu-24.04 (push) Failing after 2m13s
Matrix Smoke / distro: rocky-9 (push) Failing after 10m39s
Matrix Smoke / distro: manjaro (push) Failing after 12m11s
Matrix Smoke / distro: opensuse-tw (push) Failing after 11m53s
Matrix Smoke / distro: archlinux (push) Failing after 20m3s
Matrix Smoke / distro: ubuntu-22.04 (push) Failing after 13m49s
Validate .env Schema / tier-1-env-validation (push) Successful in 52s
Validate .env Schema / tier-2-env-validation (push) Successful in 44s
Validate .env Schema / tier-3-env-validation (push) Successful in 52s
Validate .env Schema / tier-4-env-validation (push) Successful in 51s
Validate Extensions Catalog / Check catalog is up-to-date (push) Failing after 9m47s
Secret Scan / Scan for secrets (push) Failing after 21m4s
Validate Docker Compose / Validate Docker Compose files (push) Has been cancelled
Python Type Check / Type check with mypy (push) Has been cancelled
Validate .env Schema / tier-0-env-validation (push) Has been cancelled
Test Linux / integration-smoke (push) Has been cancelled
Lint PowerShell / powershell-lint (windows-latest) (push) Has been cancelled
Matrix Smoke / macos-smoke (push) Has been cancelled
123 lines
3.3 KiB
Rust
123 lines
3.3 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use std::fs;
|
|
use std::path::PathBuf;
|
|
|
|
/// Persisted install state — survives reboots (e.g. after WSL2 install).
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct InstallState {
|
|
pub phase: InstallPhase,
|
|
pub install_dir: Option<String>,
|
|
pub detected_gpu: Option<GpuInfo>,
|
|
pub selected_tier: Option<u8>,
|
|
pub selected_features: Vec<String>,
|
|
pub error: Option<String>,
|
|
pub progress_pct: u8,
|
|
pub progress_message: String,
|
|
pub reboot_pending: bool,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum InstallPhase {
|
|
Welcome,
|
|
SystemCheck,
|
|
Prerequisites,
|
|
GpuDetection,
|
|
FeatureSelection,
|
|
Installing,
|
|
Complete,
|
|
Error,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct GpuInfo {
|
|
pub vendor: GpuVendor,
|
|
pub name: String,
|
|
pub vram_mb: u64,
|
|
pub driver_version: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum GpuVendor {
|
|
Nvidia,
|
|
Amd,
|
|
Intel,
|
|
Apple,
|
|
None,
|
|
}
|
|
|
|
impl Default for InstallState {
|
|
fn default() -> Self {
|
|
Self {
|
|
phase: InstallPhase::Welcome,
|
|
install_dir: None,
|
|
detected_gpu: None,
|
|
selected_tier: None,
|
|
selected_features: vec![],
|
|
error: None,
|
|
progress_pct: 0,
|
|
progress_message: String::new(),
|
|
reboot_pending: false,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl InstallState {
|
|
fn state_path() -> PathBuf {
|
|
let dir = dirs_next().join("ods");
|
|
let _ = fs::create_dir_all(&dir);
|
|
dir.join("installer-state.json")
|
|
}
|
|
|
|
pub fn save(&self) -> Result<(), String> {
|
|
let path = Self::state_path();
|
|
let tmp = path.with_extension("json.tmp");
|
|
let json = serde_json::to_string_pretty(self).map_err(|e| e.to_string())?;
|
|
fs::write(&tmp, json).map_err(|e| e.to_string())?;
|
|
match fs::rename(&tmp, &path) {
|
|
Ok(()) => Ok(()),
|
|
Err(err) if path.exists() => {
|
|
fs::remove_file(&path).map_err(|remove_err| remove_err.to_string())?;
|
|
fs::rename(&tmp, &path).map_err(|rename_err| {
|
|
format!(
|
|
"Failed to replace installer state after rename error ({err}): {rename_err}"
|
|
)
|
|
})
|
|
}
|
|
Err(err) => Err(err.to_string()),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl InstallState {
|
|
pub fn load() -> Option<InstallState> {
|
|
let path = Self::state_path();
|
|
let data = fs::read_to_string(path).ok()?;
|
|
serde_json::from_str(&data).ok()
|
|
}
|
|
}
|
|
|
|
fn dirs_next() -> PathBuf {
|
|
#[cfg(target_os = "windows")]
|
|
{
|
|
std::env::var("LOCALAPPDATA")
|
|
.map(PathBuf::from)
|
|
.unwrap_or_else(|_| PathBuf::from("C:\\ProgramData"))
|
|
}
|
|
#[cfg(target_os = "macos")]
|
|
{
|
|
let home = std::env::var("HOME").unwrap_or_else(|_| "/tmp".into());
|
|
PathBuf::from(home).join("Library/Application Support")
|
|
}
|
|
#[cfg(target_os = "linux")]
|
|
{
|
|
std::env::var("XDG_DATA_HOME")
|
|
.map(PathBuf::from)
|
|
.unwrap_or_else(|_| {
|
|
let home = std::env::var("HOME").unwrap_or_else(|_| "/tmp".into());
|
|
PathBuf::from(home).join(".local/share")
|
|
})
|
|
}
|
|
}
|