fixed duplicate error messages on installer failure and added new error type
This commit is contained in:
1 parent
1fd1b4e09d
commit
c5da2c7c99
12 files changed
+109
-81
No files matched your search
@@ -5,7 +5,7 @@ use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use super::{GameVersion, ModLoaderInstaller};
|
||||
use super::{GameVersion, InstallError, InstallerError, ModLoaderInstaller};
|
||||
use crate::instance::models::ModLoader;
|
||||
use crate::net::{HttpClient, NetError, fabric as fabric_api};
|
||||
|
||||
@@ -49,7 +49,7 @@ impl ModLoaderInstaller for FabricInstaller {
|
||||
loader_version: &str,
|
||||
_instance_dir: &Path,
|
||||
meta_dir: &Path,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), InstallError> {
|
||||
tracing::info!(
|
||||
"Installing Fabric {} for Minecraft {}",
|
||||
loader_version,
|
||||
@@ -67,7 +67,8 @@ impl ModLoaderInstaller for FabricInstaller {
|
||||
meta_dir,
|
||||
&format!("fabric-{game_version}-{loader_version}.json"),
|
||||
&raw_bytes,
|
||||
)?;
|
||||
)
|
||||
.map_err(InstallerError::from)?;
|
||||
tracing::debug!(
|
||||
"Saved Fabric profile for Minecraft {} loader {}",
|
||||
game_version,
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use super::{GameVersion, ModLoaderInstaller};
|
||||
use super::{GameVersion, InstallError, ModLoaderInstaller};
|
||||
use crate::instance::models::ModLoader;
|
||||
use crate::net::{HttpClient, NetError, forge as forge_api};
|
||||
|
||||
@@ -44,7 +44,7 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
loader_version: &str,
|
||||
instance_dir: &Path,
|
||||
meta_dir: &Path,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), InstallError> {
|
||||
let installer_jar = instance_dir.join(".minecraft").join("forge-installer.jar");
|
||||
tracing::info!(
|
||||
"Installing Forge {} for Minecraft {}",
|
||||
@@ -84,11 +84,12 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
forge_api::run_forge_installer(&installer_jar, instance_dir, &java_path).await
|
||||
{
|
||||
let _ = tokio::fs::remove_file(&installer_jar).await;
|
||||
return Err(e);
|
||||
return Err(InstallError::Installer(e));
|
||||
}
|
||||
|
||||
// extract the profile from what the installer just wrote to disk
|
||||
save_forge_profile(instance_dir, meta_dir, game_version, loader_version)?;
|
||||
save_forge_profile(instance_dir, meta_dir, game_version, loader_version)
|
||||
.map_err(InstallError::Installer)?;
|
||||
}
|
||||
|
||||
if let Err(e) = tokio::fs::remove_file(&installer_jar).await {
|
||||
@@ -109,7 +110,7 @@ fn save_forge_profile(
|
||||
meta_dir: &Path,
|
||||
game_version: &str,
|
||||
loader_version: &str,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), super::InstallerError> {
|
||||
let version_dir_name = format!("{game_version}-forge-{loader_version}");
|
||||
let profile_filename = format!("forge-{game_version}-{loader_version}.json");
|
||||
super::save_installer_profile(instance_dir, meta_dir, &version_dir_name, &profile_filename)
|
||||
|
||||
@@ -12,10 +12,29 @@ mod vanilla;
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::instance::models::ModLoader;
|
||||
use crate::net::{HttpClient, NetError};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum InstallerError {
|
||||
#[error("IO error: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
#[error("Process failed: {0}")]
|
||||
ProcessFailed(String),
|
||||
#[error("Profile error: {0}")]
|
||||
Profile(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum InstallError {
|
||||
#[error("Download error: {0}")]
|
||||
Download(#[from] NetError),
|
||||
#[error("Installer error: {0}")]
|
||||
Installer(#[from] InstallerError),
|
||||
}
|
||||
|
||||
pub use vanilla::VanillaInstaller;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -43,7 +62,7 @@ pub trait ModLoaderInstaller: Send + Sync {
|
||||
loader_version: &str,
|
||||
instance_dir: &Path,
|
||||
meta_dir: &Path,
|
||||
) -> Result<(), NetError>;
|
||||
) -> Result<(), InstallError>;
|
||||
}
|
||||
|
||||
// writes raw profile JSON bytes to meta_dir/loader-profiles/<filename>.
|
||||
@@ -71,7 +90,7 @@ pub(crate) fn save_installer_profile(
|
||||
meta_dir: &Path,
|
||||
version_dir_name: &str,
|
||||
profile_filename: &str,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), InstallerError> {
|
||||
let ver_json_path = instance_dir
|
||||
.join(".minecraft")
|
||||
.join("versions")
|
||||
@@ -79,11 +98,11 @@ pub(crate) fn save_installer_profile(
|
||||
.join(format!("{version_dir_name}.json"));
|
||||
|
||||
if !ver_json_path.exists() {
|
||||
tracing::error!(
|
||||
tracing::debug!(
|
||||
"Installer profile JSON missing: {}",
|
||||
ver_json_path.display()
|
||||
);
|
||||
return Err(NetError::Parse(format!(
|
||||
return Err(InstallerError::Profile(format!(
|
||||
"Version JSON not found at {}",
|
||||
ver_json_path.display()
|
||||
)));
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use super::{GameVersion, ModLoaderInstaller};
|
||||
use super::{GameVersion, InstallError, ModLoaderInstaller};
|
||||
use crate::instance::models::ModLoader;
|
||||
use crate::net::{HttpClient, NetError, neoforge as neoforge_api};
|
||||
|
||||
@@ -43,7 +43,7 @@ impl ModLoaderInstaller for NeoForgeInstaller {
|
||||
loader_version: &str,
|
||||
instance_dir: &Path,
|
||||
meta_dir: &Path,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), InstallError> {
|
||||
let installer_jar = instance_dir
|
||||
.join(".minecraft")
|
||||
.join("neoforge-installer.jar");
|
||||
@@ -62,14 +62,15 @@ impl ModLoaderInstaller for NeoForgeInstaller {
|
||||
neoforge_api::run_neoforge_installer(&installer_jar, instance_dir, &java_path).await
|
||||
{
|
||||
let _ = tokio::fs::remove_file(&installer_jar).await;
|
||||
return Err(e);
|
||||
return Err(InstallError::Installer(e));
|
||||
}
|
||||
|
||||
if let Err(e) = tokio::fs::remove_file(&installer_jar).await {
|
||||
tracing::warn!("Failed to remove NeoForge installer JAR: {}", e);
|
||||
}
|
||||
|
||||
save_neoforge_profile(instance_dir, meta_dir, loader_version)?;
|
||||
save_neoforge_profile(instance_dir, meta_dir, loader_version)
|
||||
.map_err(InstallError::Installer)?;
|
||||
|
||||
tracing::debug!("Installed NeoForge {}", loader_version);
|
||||
Ok(())
|
||||
@@ -80,7 +81,7 @@ fn save_neoforge_profile(
|
||||
instance_dir: &Path,
|
||||
meta_dir: &Path,
|
||||
loader_version: &str,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), super::InstallerError> {
|
||||
let version_dir_name = format!("neoforge-{loader_version}");
|
||||
let profile_filename = format!("neoforge-{loader_version}.json");
|
||||
super::save_installer_profile(instance_dir, meta_dir, &version_dir_name, &profile_filename)
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use super::{GameVersion, ModLoaderInstaller};
|
||||
use super::{GameVersion, InstallError, InstallerError, ModLoaderInstaller};
|
||||
use crate::instance::models::ModLoader;
|
||||
use crate::net::{HttpClient, NetError, quilt as quilt_api};
|
||||
|
||||
@@ -49,7 +49,7 @@ impl ModLoaderInstaller for QuiltInstaller {
|
||||
loader_version: &str,
|
||||
_instance_dir: &Path,
|
||||
meta_dir: &Path,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), InstallError> {
|
||||
tracing::info!(
|
||||
"Installing Quilt {} for Minecraft {}",
|
||||
loader_version,
|
||||
@@ -67,7 +67,8 @@ impl ModLoaderInstaller for QuiltInstaller {
|
||||
meta_dir,
|
||||
&format!("quilt-{game_version}-{loader_version}.json"),
|
||||
&raw_bytes,
|
||||
)?;
|
||||
)
|
||||
.map_err(InstallerError::from)?;
|
||||
tracing::debug!(
|
||||
"Saved Quilt profile for Minecraft {} loader {}",
|
||||
game_version,
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use super::{GameVersion, ModLoaderInstaller};
|
||||
use super::{GameVersion, InstallError, ModLoaderInstaller};
|
||||
use crate::instance::models::ModLoader;
|
||||
use crate::net::{HttpClient, NetError, mojang};
|
||||
|
||||
@@ -45,7 +45,7 @@ impl ModLoaderInstaller for VanillaInstaller {
|
||||
_loader_version: &str,
|
||||
_instance_dir: &Path,
|
||||
_meta_dir: &Path,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), InstallError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ use std::path::PathBuf;
|
||||
use chrono::Utc;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::instance::loader::InstallError;
|
||||
use crate::instance::loader::InstallerError;
|
||||
use crate::instance::models::{InstanceConfig, ModLoader};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
@@ -20,6 +22,8 @@ pub enum InstanceError {
|
||||
Json(#[from] serde_json::Error),
|
||||
#[error("Download error: {0}")]
|
||||
Download(#[from] crate::net::NetError),
|
||||
#[error("Installer error: {0}")]
|
||||
InstallerError(#[from] InstallerError),
|
||||
#[error("Invalid instance name: {0}")]
|
||||
InvalidName(String),
|
||||
}
|
||||
@@ -247,7 +251,11 @@ impl InstanceManager {
|
||||
instance_dir,
|
||||
&self.meta_dir,
|
||||
)
|
||||
.await?;
|
||||
.await
|
||||
.map_err(|e| match e {
|
||||
InstallError::Download(net_error) => InstanceError::Download(net_error),
|
||||
InstallError::Installer(installer_error) => InstanceError::InstallerError(installer_error),
|
||||
})?;
|
||||
|
||||
let config = InstanceConfig {
|
||||
name: name.to_string(),
|
||||
|
||||
+33
-27
@@ -7,7 +7,7 @@ use std::path::Path;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::instance::loader::GameVersion;
|
||||
use crate::instance::loader::{GameVersion, InstallError, InstallerError};
|
||||
use crate::net::{HttpClient, NetError, download_file};
|
||||
use crate::tui::progress::{set_action, set_sub_action};
|
||||
|
||||
@@ -141,7 +141,7 @@ pub async fn run_forge_installer(
|
||||
installer_path: &Path,
|
||||
instance_dir: &Path,
|
||||
java_path: &str,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), InstallerError> {
|
||||
use tokio::process::Command;
|
||||
|
||||
set_action("Running Forge installer...");
|
||||
@@ -156,13 +156,13 @@ pub async fn run_forge_installer(
|
||||
{
|
||||
Ok(o) => o,
|
||||
Err(e) => {
|
||||
tracing::error!(
|
||||
tracing::debug!(
|
||||
"Failed to spawn Forge installer {} with Java {}: {}",
|
||||
installer_path.display(),
|
||||
java_path,
|
||||
e
|
||||
);
|
||||
return Err(NetError::Io(e));
|
||||
return Err(InstallerError::Io(e));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -173,13 +173,13 @@ pub async fn run_forge_installer(
|
||||
} else {
|
||||
stderr.lines().last().unwrap_or("unknown error").to_string()
|
||||
};
|
||||
tracing::error!(
|
||||
tracing::debug!(
|
||||
"Forge installer {} failed with status {:?}: {}",
|
||||
installer_path.display(),
|
||||
output.status.code(),
|
||||
detail
|
||||
);
|
||||
return Err(NetError::InstallerFailed(detail));
|
||||
return Err(InstallerError::ProcessFailed(detail));
|
||||
}
|
||||
|
||||
tracing::debug!("Forge installer completed successfully");
|
||||
@@ -215,7 +215,7 @@ pub(crate) async fn install_forge_from_profile(
|
||||
installer_path: &Path,
|
||||
meta_dir: &Path,
|
||||
profile_filename: &str,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), InstallError> {
|
||||
use std::io::Read;
|
||||
|
||||
set_action("Installing legacy Forge from profile...");
|
||||
@@ -225,63 +225,68 @@ pub(crate) async fn install_forge_from_profile(
|
||||
meta_dir.display()
|
||||
);
|
||||
|
||||
let file = std::fs::File::open(installer_path)?;
|
||||
let file = std::fs::File::open(installer_path)
|
||||
.map_err(|e| InstallError::Installer(InstallerError::Io(e)))?;
|
||||
let mut archive = zip::ZipArchive::new(file)
|
||||
.map_err(|e| NetError::Parse(format!("Failed to open installer as ZIP: {e}")))?;
|
||||
.map_err(|e| InstallError::Installer(InstallerError::Profile(format!("Failed to open installer as ZIP: {e}"))))?;
|
||||
|
||||
let profile_data: serde_json::Value = {
|
||||
let entry = archive.by_name("install_profile.json").map_err(|e| {
|
||||
NetError::Parse(format!("install_profile.json not found in installer: {e}"))
|
||||
InstallError::Installer(InstallerError::Profile(format!("install_profile.json not found in installer: {e}")))
|
||||
})?;
|
||||
serde_json::from_reader(entry)
|
||||
.map_err(|e| NetError::Parse(format!("Failed to parse install_profile.json: {e}")))?
|
||||
.map_err(|e| InstallError::Installer(InstallerError::Profile(format!("Failed to parse install_profile.json: {e}"))))?
|
||||
};
|
||||
|
||||
let version_info = profile_data
|
||||
.get("versionInfo")
|
||||
.ok_or_else(|| NetError::Parse("install_profile.json missing versionInfo".into()))?;
|
||||
.ok_or_else(|| InstallError::Installer(InstallerError::Profile("install_profile.json missing versionInfo".into())))?;
|
||||
let install_info = profile_data
|
||||
.get("install")
|
||||
.ok_or_else(|| NetError::Parse("install_profile.json missing install section".into()))?;
|
||||
.ok_or_else(|| InstallError::Installer(InstallerError::Profile("install_profile.json missing install section".into())))?;
|
||||
|
||||
let libraries = version_info
|
||||
.get("libraries")
|
||||
.and_then(|v| v.as_array())
|
||||
.ok_or_else(|| NetError::Parse("missing versionInfo.libraries".into()))?;
|
||||
.ok_or_else(|| InstallError::Installer(InstallerError::Profile("missing versionInfo.libraries".into())))?;
|
||||
|
||||
let file_path = install_info
|
||||
.get("filePath")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or_else(|| NetError::Parse("missing install.filePath".into()))?;
|
||||
.ok_or_else(|| InstallError::Installer(InstallerError::Profile("missing install.filePath".into())))?;
|
||||
|
||||
let install_path_coord = install_info
|
||||
.get("path")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or_else(|| NetError::Parse("missing install.path".into()))?;
|
||||
.ok_or_else(|| InstallError::Installer(InstallerError::Profile("missing install.path".into())))?;
|
||||
|
||||
// extract the universal jar to the correct maven location
|
||||
let universal_maven_path =
|
||||
crate::net::maven_coord_to_path(install_path_coord).ok_or_else(|| {
|
||||
NetError::Parse(format!(
|
||||
InstallError::Installer(InstallerError::Profile(format!(
|
||||
"Invalid maven coord in install.path: {install_path_coord}"
|
||||
))
|
||||
)))
|
||||
})?;
|
||||
|
||||
set_sub_action("Extracting universal JAR...");
|
||||
let universal_dest = meta_dir.join("libraries").join(&universal_maven_path);
|
||||
if let Some(parent) = universal_dest.parent() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
std::fs::create_dir_all(parent)
|
||||
.map_err(|e| InstallError::Installer(InstallerError::Io(e)))?;
|
||||
}
|
||||
|
||||
{
|
||||
let mut entry = archive.by_name(file_path).map_err(|e| {
|
||||
NetError::Parse(format!(
|
||||
InstallError::Installer(InstallerError::Profile(format!(
|
||||
"Universal JAR '{file_path}' not found in installer: {e}"
|
||||
))
|
||||
)))
|
||||
})?;
|
||||
let mut buf = Vec::new();
|
||||
entry.read_to_end(&mut buf)?;
|
||||
std::fs::write(&universal_dest, &buf)?;
|
||||
entry
|
||||
.read_to_end(&mut buf)
|
||||
.map_err(|e| InstallError::Installer(InstallerError::Io(e)))?;
|
||||
std::fs::write(&universal_dest, &buf)
|
||||
.map_err(|e| InstallError::Installer(InstallerError::Io(e)))?;
|
||||
tracing::debug!(
|
||||
"Extracted legacy Forge universal JAR to {} ({} bytes)",
|
||||
universal_dest.display(),
|
||||
@@ -295,12 +300,12 @@ pub(crate) async fn install_forge_from_profile(
|
||||
// in mojang's modern version metadata, so we fetch those too.
|
||||
let libraries_dir = meta_dir.join("libraries");
|
||||
for lib in libraries {
|
||||
let name = lib.get("name").and_then(|v| v.as_str()).unwrap_or_default();
|
||||
let name = lib.get("name").and_then(|v| v.as_str()).unwrap_or_default();
|
||||
|
||||
let maven_path = match crate::net::maven_coord_to_path(name) {
|
||||
Some(p) => p,
|
||||
None => {
|
||||
return Err(NetError::Parse(format!("Invalid Maven coordinate: {name}")));
|
||||
return Err(InstallError::Installer(InstallerError::Profile(format!("Invalid Maven coordinate: {name}"))));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -337,8 +342,9 @@ pub(crate) async fn install_forge_from_profile(
|
||||
// the source is a serde_json::Value (which doesn't preserve order),
|
||||
// but no field is silently dropped.
|
||||
let serialized = serde_json::to_vec(version_info)
|
||||
.map_err(|e| NetError::Parse(format!("Failed to serialize Forge profile: {e}")))?;
|
||||
crate::instance::loader::save_profile_bytes(meta_dir, profile_filename, &serialized)?;
|
||||
.map_err(|e| InstallError::Installer(InstallerError::Profile(format!("Failed to serialize Forge profile: {e}"))))?;
|
||||
crate::instance::loader::save_profile_bytes(meta_dir, profile_filename, &serialized)
|
||||
.map_err(|e| InstallError::Installer(InstallerError::Io(e)))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ pub enum NetError {
|
||||
Parse(String),
|
||||
#[error("Server returned error status {status}: {url}")]
|
||||
StatusError { status: u16, url: String },
|
||||
#[error("Installer process failed: {0}")]
|
||||
InstallerFailed(String),
|
||||
#[error("Task failed: {0}")]
|
||||
TaskFailed(String),
|
||||
}
|
||||
|
||||
+5
-5
@@ -289,7 +289,7 @@ pub async fn download_assets_from(
|
||||
match tokio::fs::create_dir_all(parent).await {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to create asset index dir: {}", e);
|
||||
tracing::debug!("Failed to create asset index dir: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,7 +298,7 @@ pub async fn download_assets_from(
|
||||
tracing::debug!("Saved asset index to {}", index_path.display());
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!(
|
||||
tracing::debug!(
|
||||
"Failed to write asset index {}: {}",
|
||||
index_path.display(),
|
||||
e
|
||||
@@ -307,7 +307,7 @@ pub async fn download_assets_from(
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to serialize asset index: {}", e);
|
||||
tracing::debug!("Failed to serialize asset index: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -394,13 +394,13 @@ async fn run_parallel_downloads(
|
||||
set_sub_action(label);
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
tracing::error!("Download failed: {}", e);
|
||||
tracing::debug!("Download failed: {}", e);
|
||||
if first_error.is_none() {
|
||||
first_error = Some(e);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("Task panicked: {}", e);
|
||||
tracing::debug!("Task panicked: {}", e);
|
||||
if first_error.is_none() {
|
||||
first_error = Some(NetError::TaskFailed(format!("Join error: {}", e)));
|
||||
}
|
||||
|
||||
+6
-5
@@ -8,6 +8,7 @@ use std::path::Path;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::instance::loader::GameVersion;
|
||||
use crate::instance::loader::InstallerError;
|
||||
use crate::net::{HttpClient, NetError, download_file};
|
||||
use crate::tui::progress::set_action;
|
||||
|
||||
@@ -171,7 +172,7 @@ pub async fn run_neoforge_installer(
|
||||
installer_path: &Path,
|
||||
instance_dir: &Path,
|
||||
java_path: &str,
|
||||
) -> Result<(), NetError> {
|
||||
) -> Result<(), InstallerError> {
|
||||
use tokio::process::Command;
|
||||
|
||||
set_action("Running NeoForge installer...");
|
||||
@@ -186,26 +187,26 @@ pub async fn run_neoforge_installer(
|
||||
{
|
||||
Ok(o) => o,
|
||||
Err(e) => {
|
||||
tracing::error!(
|
||||
tracing::debug!(
|
||||
"Failed to spawn NeoForge installer {} with Java {}: {}",
|
||||
installer_path.display(),
|
||||
java_path,
|
||||
e
|
||||
);
|
||||
return Err(NetError::Io(e));
|
||||
return Err(InstallerError::Io(e));
|
||||
}
|
||||
};
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
let detail = stderr.lines().last().unwrap_or("").trim();
|
||||
tracing::error!(
|
||||
tracing::debug!(
|
||||
"NeoForge installer {} failed with status {:?}: {}",
|
||||
installer_path.display(),
|
||||
output.status.code(),
|
||||
detail
|
||||
);
|
||||
return Err(NetError::InstallerFailed(format!(
|
||||
return Err(InstallerError::ProcessFailed(format!(
|
||||
"NeoForge installer exited with {:?}",
|
||||
output.status.code()
|
||||
)));
|
||||
|
||||
+11
-19
@@ -71,14 +71,10 @@ impl App {
|
||||
match key_event.code {
|
||||
KeyCode::Enter | KeyCode::Char('y') | KeyCode::Char('Y') => {
|
||||
let name = confirm_popup::pending_delete_name();
|
||||
if !name.is_empty() {
|
||||
match self.instance_manager.delete(&name) {
|
||||
Ok(_) => {
|
||||
self.instances_state.remove_instance(&name);
|
||||
}
|
||||
Err(_) => {}
|
||||
if !name.is_empty()
|
||||
&& let Ok(_) = self.instance_manager.delete(&name) {
|
||||
self.instances_state.remove_instance(&name);
|
||||
}
|
||||
}
|
||||
confirm_popup::clear_pending();
|
||||
self.focused = FocusedArea::Instances;
|
||||
return Ok(());
|
||||
@@ -190,19 +186,15 @@ impl App {
|
||||
let new_name = self.instances_state.renaming.take().unwrap_or_default();
|
||||
if let Some(inst) = self.instances_state.selected_instance() {
|
||||
let old_name = inst.name.clone();
|
||||
match self.instance_manager.rename(&old_name, &new_name) {
|
||||
Ok(()) => {
|
||||
if let Some(inst) = self
|
||||
.instances_state
|
||||
.instances
|
||||
.iter_mut()
|
||||
.find(|i| i.name == old_name)
|
||||
{
|
||||
inst.name = new_name.trim().to_owned();
|
||||
}
|
||||
if let Ok(()) = self.instance_manager.rename(&old_name, &new_name)
|
||||
&& let Some(inst) = self
|
||||
.instances_state
|
||||
.instances
|
||||
.iter_mut()
|
||||
.find(|i| i.name == old_name)
|
||||
{
|
||||
inst.name = new_name.trim().to_owned();
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
KeyCode::Esc => {
|
||||
|
||||
Reference in new issue
Block a user