You've already forked AstralRinth
forked from didirus/AstralRinth
Compiler improvements (#145)
* Initial bug fixes * fix compile error on non-mac * Fix even more bugs * Fix more * fix more * fix build * fix build * working basic * removed zip * working functions * merge fixes * fixed loadintg bar bug * changed to one layer deep * forge version numbers * improvements + refactoring * renamed things to fit plugin * fixed bugs * removed println * overrides dont include mrpack * merge * fixes * fixes * fixed deletion * merge errors * force sync before export * removed testing * missed line * removed console log * mac error reverted * incoreclty named helper * added to new register method * review changes * minor changes * moved create pack * renamed function --------- Co-authored-by: Jai A <jaiagr+gpg@pm.me>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::launcher::auth::Credentials;
|
||||
use std::mem;
|
||||
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
// Authentication task
|
||||
@@ -43,7 +43,7 @@ impl AuthTask {
|
||||
let state = crate::State::get().await?;
|
||||
let mut write = state.auth_flow.write().await;
|
||||
|
||||
mem::replace(&mut write.0, None)
|
||||
write.0.take()
|
||||
};
|
||||
|
||||
// Waits for the task to complete, and returns the credentials
|
||||
@@ -61,7 +61,7 @@ impl AuthTask {
|
||||
let state = crate::State::get().await?;
|
||||
let mut write = state.auth_flow.write().await;
|
||||
|
||||
mem::replace(&mut write.0, None)
|
||||
write.0.take()
|
||||
};
|
||||
if let Some(task) = task {
|
||||
// Cancels the task
|
||||
|
||||
@@ -224,7 +224,40 @@ impl Profile {
|
||||
|
||||
pub fn sync_projects_task(path: PathBuf) {
|
||||
tokio::task::spawn(async move {
|
||||
let res = Self::sync_projects_inner(path).await;
|
||||
let res = async {
|
||||
let state = State::get().await?;
|
||||
let profile = crate::api::profile::get(&path, None).await?;
|
||||
|
||||
if let Some(profile) = profile {
|
||||
let paths = profile.get_profile_project_paths()?;
|
||||
|
||||
let projects = crate::state::infer_data_from_files(
|
||||
profile.clone(),
|
||||
paths,
|
||||
state.directories.caches_dir(),
|
||||
&state.io_semaphore,
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let mut new_profiles = state.profiles.write().await;
|
||||
if let Some(profile) = new_profiles.0.get_mut(&path) {
|
||||
profile.projects = projects;
|
||||
}
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Synced,
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
tracing::warn!(
|
||||
"Unable to fetch single profile projects: path {path:?} invalid",
|
||||
);
|
||||
}
|
||||
Ok::<(), crate::Error>(())
|
||||
}.await;
|
||||
match res {
|
||||
Ok(()) => {}
|
||||
Err(err) => {
|
||||
@@ -236,42 +269,6 @@ impl Profile {
|
||||
});
|
||||
}
|
||||
|
||||
pub async fn sync_projects_inner(path: PathBuf) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
let profile = crate::api::profile::get(&path, None).await?;
|
||||
|
||||
if let Some(profile) = profile {
|
||||
let paths = profile.get_profile_project_paths()?;
|
||||
|
||||
let projects = crate::state::infer_data_from_files(
|
||||
profile.clone(),
|
||||
paths,
|
||||
state.directories.caches_dir(),
|
||||
&state.io_semaphore,
|
||||
&state.fetch_semaphore,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let mut new_profiles = state.profiles.write().await;
|
||||
if let Some(profile) = new_profiles.0.get_mut(&path) {
|
||||
profile.projects = projects;
|
||||
}
|
||||
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Synced,
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
tracing::warn!(
|
||||
"Unable to fetch single profile projects: path {path:?} invalid",
|
||||
);
|
||||
}
|
||||
Ok::<(), crate::Error>(())
|
||||
}
|
||||
|
||||
pub fn get_profile_project_paths(&self) -> crate::Result<Vec<PathBuf>> {
|
||||
let mut files = Vec::new();
|
||||
let mut read_paths = |path: &str| {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
//! Theseus settings file
|
||||
use crate::{jre, State};
|
||||
use crate::{
|
||||
jre::{self, autodetect_java_globals, find_filtered_jres},
|
||||
State,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::Path;
|
||||
use tokio::fs;
|
||||
@@ -89,7 +92,16 @@ impl Settings {
|
||||
|
||||
if settings_read.java_globals.count() == 0 {
|
||||
drop(settings_read);
|
||||
let java_globals = jre::autodetect_java_globals().await?;
|
||||
let jres = jre::get_all_jre().await?;
|
||||
let java_8 =
|
||||
find_filtered_jres("1.8", jres.clone(), false).await?;
|
||||
let java_17 =
|
||||
find_filtered_jres("1.17", jres.clone(), false).await?;
|
||||
let java_18plus =
|
||||
find_filtered_jres("1.18", jres.clone(), true).await?;
|
||||
let java_globals =
|
||||
autodetect_java_globals(java_8, java_17, java_18plus)
|
||||
.await?;
|
||||
state.settings.write().await.java_globals = java_globals;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user