You've already forked AstralRinth
forked from didirus/AstralRinth
fixes (#449)
* fixes * prettier * more bugs * changes * more fixes * prettier, fmt, clippy * fix regressed error * println, console.log * fix imports --------- Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com> Co-authored-by: Jai A <jaiagr+gpg@pm.me>
This commit is contained in:
@@ -104,7 +104,7 @@ pub async fn profile_create(
|
||||
|
||||
emit_profile(
|
||||
uuid,
|
||||
profile.get_profile_full_path().await?,
|
||||
&profile.profile_id(),
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Created,
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ pub async fn remove(path: &ProfilePathId) -> crate::Result<()> {
|
||||
if let Some(profile) = profiles.remove(path).await? {
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.get_profile_full_path().await?,
|
||||
path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Removed,
|
||||
)
|
||||
@@ -124,7 +124,7 @@ where
|
||||
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.get_profile_full_path().await?,
|
||||
path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
@@ -162,7 +162,7 @@ pub async fn edit_icon(
|
||||
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.get_profile_full_path().await?,
|
||||
path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
@@ -285,7 +285,6 @@ pub async fn update_all_projects(
|
||||
)
|
||||
.await?;
|
||||
|
||||
let profile_base_path = profile.get_profile_full_path().await?;
|
||||
let keys = profile
|
||||
.projects
|
||||
.into_iter()
|
||||
@@ -331,7 +330,7 @@ pub async fn update_all_projects(
|
||||
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile_base_path,
|
||||
profile_path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
@@ -378,10 +377,12 @@ pub async fn update_project(
|
||||
if let Some(mut project) = value {
|
||||
if let ProjectMetadata::Modrinth {
|
||||
ref mut version,
|
||||
ref mut update_version,
|
||||
..
|
||||
} = project.metadata
|
||||
{
|
||||
*version = Box::new(new_version);
|
||||
*update_version = None;
|
||||
}
|
||||
profile.projects.insert(path.clone(), project);
|
||||
}
|
||||
@@ -391,7 +392,7 @@ pub async fn update_project(
|
||||
if !skip_send_event.unwrap_or(false) {
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.get_profile_full_path().await?,
|
||||
profile_path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
@@ -427,7 +428,7 @@ pub async fn add_project_from_version(
|
||||
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.get_profile_full_path().await?,
|
||||
profile_path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
@@ -467,7 +468,7 @@ pub async fn add_project_from_path(
|
||||
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.get_profile_full_path().await?,
|
||||
profile_path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
@@ -488,15 +489,15 @@ pub async fn add_project_from_path(
|
||||
/// returns the new state, relative to the profile
|
||||
#[tracing::instrument]
|
||||
pub async fn toggle_disable_project(
|
||||
profile: &ProfilePathId,
|
||||
profile_path: &ProfilePathId,
|
||||
project: &ProjectPathId,
|
||||
) -> crate::Result<ProjectPathId> {
|
||||
if let Some(profile) = get(profile, None).await? {
|
||||
if let Some(profile) = get(profile_path, None).await? {
|
||||
let res = profile.toggle_disable_project(project).await?;
|
||||
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.get_profile_full_path().await?,
|
||||
profile_path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
@@ -505,8 +506,10 @@ pub async fn toggle_disable_project(
|
||||
|
||||
Ok(res)
|
||||
} else {
|
||||
Err(crate::ErrorKind::UnmanagedProfileError(profile.to_string())
|
||||
.as_error())
|
||||
Err(
|
||||
crate::ErrorKind::UnmanagedProfileError(profile_path.to_string())
|
||||
.as_error(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,15 +517,15 @@ pub async fn toggle_disable_project(
|
||||
/// Uses and returns the relative path to the project
|
||||
#[tracing::instrument]
|
||||
pub async fn remove_project(
|
||||
profile: &ProfilePathId,
|
||||
profile_path: &ProfilePathId,
|
||||
project: &ProjectPathId,
|
||||
) -> crate::Result<()> {
|
||||
if let Some(profile) = get(profile, None).await? {
|
||||
if let Some(profile) = get(profile_path, None).await? {
|
||||
profile.remove_project(project, None).await?;
|
||||
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.get_profile_full_path().await?,
|
||||
profile_path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
@@ -531,8 +534,10 @@ pub async fn remove_project(
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
Err(crate::ErrorKind::UnmanagedProfileError(profile.to_string())
|
||||
.as_error())
|
||||
Err(
|
||||
crate::ErrorKind::UnmanagedProfileError(profile_path.to_string())
|
||||
.as_error(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1032,5 +1037,5 @@ pub async fn build_folder(
|
||||
}
|
||||
|
||||
pub fn sanitize_profile_name(input: &str) -> String {
|
||||
input.replace(['/', '\\'], "_")
|
||||
input.replace(['/', '\\', ':'], "_")
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ pub async fn update_managed_modrinth(
|
||||
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.path,
|
||||
profile_path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
@@ -133,7 +133,7 @@ pub async fn repair_managed_modrinth(
|
||||
|
||||
emit_profile(
|
||||
profile.uuid,
|
||||
profile.path,
|
||||
profile_path,
|
||||
&profile.metadata.name,
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user