Bug fixes round 3 (#298)

* fixed bugs

* title case

* bugs; ioerror

* reset breadcrumbs

* more fixes

* more fixes

* scrolling bug

* more fixes

* more fixes

* clippy

* canonicalize fix

* fixed requested changes

* removed debouncer update
This commit is contained in:
Wyatt Verchere
2023-07-19 14:13:25 -07:00
committed by GitHub
parent 6650cc9ce4
commit 1f478ec9fc
34 changed files with 932 additions and 602 deletions

View File

@@ -3,7 +3,7 @@
use super::{auth::Credentials, parse_rule};
use crate::{
state::{MemorySettings, WindowSize},
util::platform::classpath_separator,
util::{io::IOError, platform::classpath_separator},
};
use daedalus::{
get_path_from_artifact,
@@ -393,7 +393,8 @@ pub async fn get_processor_main_class(
path: String,
) -> crate::Result<Option<String>> {
let main_class = tokio::task::spawn_blocking(move || {
let zipfile = std::fs::File::open(&path)?;
let zipfile = std::fs::File::open(&path)
.map_err(|e| IOError::with_path(e, &path))?;
let mut archive = zip::ZipArchive::new(zipfile).map_err(|_| {
crate::ErrorKind::LauncherError(format!(
"Cannot read processor at {}",
@@ -413,7 +414,7 @@ pub async fn get_processor_main_class(
let reader = BufReader::new(file);
for line in reader.lines() {
let mut line = line?;
let mut line = line.map_err(IOError::from)?;
line.retain(|c| !c.is_whitespace());
if line.starts_with("Main-Class:") {

View File

@@ -6,7 +6,7 @@ use crate::{
LoadingBarId,
},
state::State,
util::{fetch::*, platform::OsExt},
util::{fetch::*, io, platform::OsExt},
};
use daedalus::{
self as d,
@@ -17,7 +17,7 @@ use daedalus::{
modded::LoaderVersion,
};
use futures::prelude::*;
use tokio::{fs, sync::OnceCell};
use tokio::sync::OnceCell;
#[tracing::instrument(skip(st, version))]
pub async fn download_minecraft(
@@ -71,7 +71,7 @@ pub async fn download_version_info(
.join(format!("{version_id}.json"));
let res = if path.exists() && !force.unwrap_or(false) {
fs::read(path)
io::read(path)
.err_into::<crate::Error>()
.await
.and_then(|ref it| Ok(serde_json::from_slice(it)?))
@@ -152,7 +152,7 @@ pub async fn download_assets_index(
.join(format!("{}.json", &version.asset_index.id));
let res = if path.exists() {
fs::read(path)
io::read(path)
.err_into::<crate::Error>()
.await
.and_then(|ref it| Ok(serde_json::from_slice(it)?))
@@ -245,8 +245,8 @@ pub async fn download_libraries(
tracing::debug!("Loading libraries");
tokio::try_join! {
fs::create_dir_all(st.directories.libraries_dir()),
fs::create_dir_all(st.directories.version_natives_dir(version))
io::create_dir_all(st.directories.libraries_dir()),
io::create_dir_all(st.directories.version_natives_dir(version))
}?;
let num_files = libraries.len();
loading_try_for_each_concurrent(

View File

@@ -1,9 +1,10 @@
//! Logic for launching Minecraft
use crate::event::emit::{emit_loading, init_or_edit_loading};
use crate::event::{LoadingBarId, LoadingBarType};
use crate::jre::{JAVA_17_KEY, JAVA_18PLUS_KEY, JAVA_8_KEY};
use crate::jre::{self, JAVA_17_KEY, JAVA_18PLUS_KEY, JAVA_8_KEY};
use crate::prelude::JavaVersion;
use crate::state::ProfileInstallStage;
use crate::util::io;
use crate::EventState;
use crate::{
process,
@@ -13,10 +14,8 @@ use crate::{
use chrono::Utc;
use daedalus as d;
use daedalus::minecraft::VersionInfo;
use dunce::canonicalize;
use st::Profile;
use std::collections::HashMap;
use std::fs;
use std::{process::Stdio, sync::Arc};
use tokio::process::Command;
use uuid::Uuid;
@@ -125,7 +124,7 @@ pub async fn install_minecraft(
State::sync().await?;
let state = State::get().await?;
let instance_path = &canonicalize(&profile.path)?;
let instance_path = &io::canonicalize(&profile.path)?;
let metadata = state.metadata.read().await;
let version = metadata
@@ -160,7 +159,7 @@ pub async fn install_minecraft(
.await?
.ok_or_else(|| {
crate::ErrorKind::OtherError(
"No available java installation".to_string(),
"Missing correct java installation".to_string(),
)
})?;
@@ -282,7 +281,7 @@ pub async fn install_minecraft(
Ok(())
}
#[tracing::instrument]
#[tracing::instrument(skip_all)]
#[theseus_macros::debug_pin]
#[allow(clippy::too_many_arguments)]
pub async fn launch_minecraft(
@@ -310,7 +309,7 @@ pub async fn launch_minecraft(
let state = State::get().await?;
let metadata = state.metadata.read().await;
let instance_path = &canonicalize(&profile.path)?;
let instance_path = &io::canonicalize(&profile.path)?;
let version = metadata
.minecraft
@@ -343,10 +342,20 @@ pub async fn launch_minecraft(
.await?
.ok_or_else(|| {
crate::ErrorKind::LauncherError(
"No available java installation".to_string(),
"Missing correct java installation".to_string(),
)
})?;
// Test jre version
let java_version = jre::check_jre(java_version.path.clone().into())
.await?
.ok_or_else(|| {
crate::ErrorKind::LauncherError(format!(
"Java path invalid or non-functional: {}",
java_version.path
))
})?;
let client_path = state
.directories
.version_dir(&version_jar)
@@ -433,7 +442,7 @@ pub async fn launch_minecraft(
.profile_logs_dir(profile.uuid)
.join(&datetime_string)
};
fs::create_dir_all(&logs_dir)?;
io::create_dir_all(&logs_dir).await?;
let stdout_log_path = logs_dir.join("stdout.log");