You've already forked AstralRinth
forked from didirus/AstralRinth
Bug fixes (#406)
* skip duplicates * slash, exports * fullscreen, exports * more bugs * fixed mac title bar * filters should go to top of page when changed * mac err, loading bars * temporary comments * moving to mac * bug fixes, fmt, prettier * review fixes * rev fixes
This commit is contained in:
@@ -29,7 +29,7 @@ pub mod prelude {
|
||||
profile::{self, create, Profile},
|
||||
settings,
|
||||
state::JavaGlobals,
|
||||
state::{ProfilePathId, ProjectPathId},
|
||||
state::{Dependency, ProfilePathId, ProjectPathId},
|
||||
util::{
|
||||
io::{canonicalize, IOError},
|
||||
jre::JavaVersion,
|
||||
|
||||
@@ -155,7 +155,7 @@ pub fn get_profile_from_pack(
|
||||
},
|
||||
CreatePackLocation::FromFile { path } => {
|
||||
let file_name = path
|
||||
.file_name()
|
||||
.file_stem()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! Theseus profile management interface
|
||||
use crate::pack::install_from::CreatePackProfile;
|
||||
use crate::prelude::ProfilePathId;
|
||||
use crate::profile;
|
||||
use crate::state::LinkedData;
|
||||
use crate::util::io::{self, canonicalize};
|
||||
use crate::{
|
||||
@@ -32,11 +33,14 @@ pub async fn profile_create(
|
||||
linked_data: Option<LinkedData>, // the linked project ID (mainly for modpacks)- used for updating
|
||||
skip_install_profile: Option<bool>,
|
||||
) -> crate::Result<ProfilePathId> {
|
||||
name = profile::sanitize_profile_name(&name);
|
||||
|
||||
trace!("Creating new profile. {}", name);
|
||||
let state = State::get().await?;
|
||||
let uuid = Uuid::new_v4();
|
||||
|
||||
let mut path = state.directories.profiles_dir().await.join(&name);
|
||||
|
||||
if path.exists() {
|
||||
let mut new_name;
|
||||
let mut new_path;
|
||||
|
||||
@@ -623,24 +623,22 @@ pub async fn export_mrpack(
|
||||
|
||||
// Get highest level folder pair ('a/b' in 'a/b/c', 'a' in 'a')
|
||||
// We only go one layer deep for the sake of not having a huge list of overrides
|
||||
let topmost_two = relative_path
|
||||
.iter()
|
||||
.take(2)
|
||||
.map(|os| os.to_string_lossy().to_string())
|
||||
.collect::<Vec<_>>();
|
||||
let topmost_two = relative_path.iter().take(2).collect::<Vec<_>>();
|
||||
|
||||
// a,b => a/b
|
||||
// a => a
|
||||
let topmost = match topmost_two.len() {
|
||||
2 => topmost_two.join("/"),
|
||||
1 => topmost_two[0].clone(),
|
||||
2 => PathBuf::from(topmost_two[0]).join(topmost_two[1]),
|
||||
1 => PathBuf::from(topmost_two[0]),
|
||||
_ => {
|
||||
return Err(crate::ErrorKind::OtherError(
|
||||
"No topmost folder found".to_string(),
|
||||
)
|
||||
.into())
|
||||
}
|
||||
};
|
||||
}
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
|
||||
if !included_overrides.contains(&topmost) {
|
||||
continue;
|
||||
@@ -851,13 +849,14 @@ pub async fn run_credentials(
|
||||
};
|
||||
|
||||
// Any options.txt settings that we want set, add here
|
||||
let mc_set_options: Vec<(String, String)> = vec![(
|
||||
"fullscreen".to_string(),
|
||||
profile
|
||||
.fullscreen
|
||||
.unwrap_or(settings.force_fullscreen)
|
||||
.to_string(),
|
||||
)];
|
||||
let mut mc_set_options: Vec<(String, String)> = vec![];
|
||||
if let Some(fullscreen) = profile.fullscreen {
|
||||
// Profile fullscreen setting takes priority
|
||||
mc_set_options.push(("fullscreen".to_string(), fullscreen.to_string()));
|
||||
} else if settings.force_fullscreen {
|
||||
// If global settings wants to force a fullscreen, do it
|
||||
mc_set_options.push(("fullscreen".to_string(), "true".to_string()));
|
||||
}
|
||||
|
||||
let mc_process = crate::launcher::launch_minecraft(
|
||||
java_args,
|
||||
@@ -929,15 +928,11 @@ pub async fn create_mrpack_json(
|
||||
.map(|(k, v)| (k, sanitize_loader_version_string(&v).to_string()))
|
||||
.collect::<HashMap<_, _>>();
|
||||
|
||||
let profile_base_path = profile.get_profile_full_path().await?;
|
||||
let files: Result<Vec<PackFile>, crate::ErrorKind> = profile
|
||||
.projects
|
||||
.iter()
|
||||
.filter_map(|(mod_path, project)| {
|
||||
let path: String = profile_base_path
|
||||
.join(mod_path.0.clone())
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
let path: String = mod_path.0.clone().to_string_lossy().to_string();
|
||||
|
||||
// Only Modrinth projects have a modrinth metadata field for the modrinth.json
|
||||
Some(Ok(match project.metadata {
|
||||
@@ -1035,3 +1030,7 @@ pub async fn build_folder(
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn sanitize_profile_name(input: &str) -> String {
|
||||
input.replace(['/', '\\'], "_")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user