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(['/', '\\'], "_")
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::util::fetch::{
|
||||
fetch_json, write_cached_icon, FetchSemaphore, IoSemaphore,
|
||||
};
|
||||
use crate::util::io::IOError;
|
||||
|
||||
use async_zip::tokio::read::fs::ZipFileReader;
|
||||
use chrono::{DateTime, Utc};
|
||||
use futures::StreamExt;
|
||||
@@ -49,6 +50,27 @@ impl ProjectType {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_from_parent_folder(path: PathBuf) -> Option<Self> {
|
||||
// Get parent folder
|
||||
let path = path.parent()?.file_name()?;
|
||||
match path.to_str()? {
|
||||
"mods" => Some(ProjectType::Mod),
|
||||
"datapacks" => Some(ProjectType::DataPack),
|
||||
"resourcepacks" => Some(ProjectType::ResourcePack),
|
||||
"shaderpacks" => Some(ProjectType::ShaderPack),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_name(&self) -> &'static str {
|
||||
match self {
|
||||
ProjectType::Mod => "mod",
|
||||
ProjectType::DataPack => "datapack",
|
||||
ProjectType::ResourcePack => "resourcepack",
|
||||
ProjectType::ShaderPack => "shaderpack",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_folder(&self) -> &'static str {
|
||||
match self {
|
||||
ProjectType::Mod => "mods",
|
||||
@@ -439,6 +461,8 @@ pub async fn infer_data_from_files(
|
||||
));
|
||||
continue;
|
||||
};
|
||||
|
||||
// Forge
|
||||
let zip_index_option = zip_file_reader
|
||||
.file()
|
||||
.entries()
|
||||
@@ -512,6 +536,7 @@ pub async fn infer_data_from_files(
|
||||
}
|
||||
}
|
||||
|
||||
// Forge
|
||||
let zip_index_option = zip_file_reader
|
||||
.file()
|
||||
.entries()
|
||||
@@ -572,6 +597,7 @@ pub async fn infer_data_from_files(
|
||||
}
|
||||
}
|
||||
|
||||
// Fabric
|
||||
let zip_index_option = zip_file_reader
|
||||
.file()
|
||||
.entries()
|
||||
@@ -641,6 +667,7 @@ pub async fn infer_data_from_files(
|
||||
}
|
||||
}
|
||||
|
||||
// Quilt
|
||||
let zip_index_option = zip_file_reader
|
||||
.file()
|
||||
.entries()
|
||||
@@ -717,6 +744,7 @@ pub async fn infer_data_from_files(
|
||||
}
|
||||
}
|
||||
|
||||
// Other
|
||||
let zip_index_option = zip_file_reader
|
||||
.file()
|
||||
.entries()
|
||||
@@ -745,6 +773,10 @@ pub async fn infer_data_from_files(
|
||||
io_semaphore,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Guess the project type from the filepath
|
||||
let project_type =
|
||||
ProjectType::get_from_parent_folder(path.clone());
|
||||
return_projects.push((
|
||||
path.clone(),
|
||||
Project {
|
||||
@@ -757,7 +789,8 @@ pub async fn infer_data_from_files(
|
||||
authors: Vec::new(),
|
||||
version: None,
|
||||
icon,
|
||||
project_type: None,
|
||||
project_type: project_type
|
||||
.map(|x| x.get_name().to_string()),
|
||||
},
|
||||
},
|
||||
));
|
||||
@@ -778,7 +811,6 @@ pub async fn infer_data_from_files(
|
||||
}
|
||||
|
||||
// Project paths should be relative
|
||||
let _profile_base_path = profile.get_profile_full_path().await?;
|
||||
let mut corrected_hashmap = HashMap::new();
|
||||
let mut stream = tokio_stream::iter(return_projects);
|
||||
while let Some((h, v)) = stream.next().await {
|
||||
|
||||
Reference in New Issue
Block a user