Initial bug fixes (#127)

* Initial bug fixes

* fix compile error on non-mac

* Fix even more bugs

* Fix more

* fix more

* fix build

* fix build

* address review comments
This commit is contained in:
Geometrically
2023-06-02 07:09:46 -07:00
committed by GitHub
parent 9ea548cfe3
commit ee61951698
57 changed files with 3823 additions and 2813 deletions

View File

@@ -71,6 +71,8 @@ where
match profiles.0.get_mut(path) {
Some(ref mut profile) => {
action(profile).await?;
emit_profile(
profile.uuid,
profile.path.clone(),
@@ -79,7 +81,7 @@ where
)
.await?;
action(profile).await
Ok(())
}
None => Err(crate::ErrorKind::UnmanagedProfileError(
path.display().to_string(),
@@ -102,6 +104,15 @@ pub async fn edit_icon(
match profiles.0.get_mut(path) {
Some(ref mut profile) => {
profile
.set_icon(
&state.directories.caches_dir(),
&state.io_semaphore,
bytes::Bytes::from(bytes),
&icon.to_string_lossy(),
)
.await?;
emit_profile(
profile.uuid,
profile.path.clone(),
@@ -110,14 +121,7 @@ pub async fn edit_icon(
)
.await?;
profile
.set_icon(
&state.directories.caches_dir(),
&state.io_semaphore,
bytes::Bytes::from(bytes),
&icon.to_string_lossy(),
)
.await
Ok(())
}
None => Err(crate::ErrorKind::UnmanagedProfileError(
path.display().to_string(),
@@ -265,7 +269,8 @@ pub async fn update_all(
async move {
let new_path =
update_project(profile_path, &project).await?;
update_project(profile_path, &project, Some(true))
.await?;
map.write().await.insert(project, new_path);
@@ -276,6 +281,14 @@ pub async fn update_all(
)
.await?;
emit_profile(
profile.uuid,
profile.path,
&profile.metadata.name,
ProfilePayloadType::Edited,
)
.await?;
Ok(Arc::try_unwrap(map).unwrap().into_inner())
} else {
Err(crate::ErrorKind::UnmanagedProfileError(
@@ -290,6 +303,7 @@ pub async fn update_all(
pub async fn update_project(
profile_path: &Path,
project_path: &Path,
skip_send_event: Option<bool>,
) -> crate::Result<PathBuf> {
if let Some(profile) = get(profile_path, None).await? {
if let Some(project) = profile.projects.get(project_path) {
@@ -322,6 +336,16 @@ pub async fn update_project(
}
}
if !skip_send_event.unwrap_or(false) {
emit_profile(
profile.uuid,
profile.path,
&profile.metadata.name,
ProfilePayloadType::Edited,
)
.await?;
}
return Ok(path);
}
}
@@ -347,6 +371,14 @@ pub async fn add_project_from_version(
if let Some(profile) = get(profile_path, None).await? {
let (path, _) = profile.add_project_version(version_id).await?;
emit_profile(
profile.uuid,
profile.path,
&profile.metadata.name,
ProfilePayloadType::Edited,
)
.await?;
Ok(path)
} else {
Err(crate::ErrorKind::UnmanagedProfileError(
@@ -379,6 +411,14 @@ pub async fn add_project_from_path(
)
.await?;
emit_profile(
profile.uuid,
profile.path,
&profile.metadata.name,
ProfilePayloadType::Edited,
)
.await?;
Ok(path)
} else {
Err(crate::ErrorKind::UnmanagedProfileError(
@@ -395,7 +435,17 @@ pub async fn toggle_disable_project(
project: &Path,
) -> crate::Result<PathBuf> {
if let Some(profile) = get(profile, None).await? {
Ok(profile.toggle_disable_project(project).await?)
let res = profile.toggle_disable_project(project).await?;
emit_profile(
profile.uuid,
profile.path,
&profile.metadata.name,
ProfilePayloadType::Edited,
)
.await?;
Ok(res)
} else {
Err(crate::ErrorKind::UnmanagedProfileError(
profile.display().to_string(),
@@ -413,6 +463,14 @@ pub async fn remove_project(
if let Some(profile) = get(profile, None).await? {
profile.remove_project(project, None).await?;
emit_profile(
profile.uuid,
profile.path,
&profile.metadata.name,
ProfilePayloadType::Edited,
)
.await?;
Ok(())
} else {
Err(crate::ErrorKind::UnmanagedProfileError(