Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ pub(crate) async fn switch_project_version_with_dependencies(
}

if new_path != project_path {
rename_project_companion_file(
instance_id,
project_path,
&new_path,
state,
)
.await?;
remove_project(instance_id, project_path, state).await?;
}

Expand Down Expand Up @@ -724,6 +731,34 @@ pub(crate) async fn remove_project(
Ok(())
}

pub(crate) async fn rename_project_companion_file(
instance_id: &str,
old_project_path: &str,
new_project_path: &str,
state: &State,
) -> crate::Result<()> {
let project_type = ProjectType::get_from_parent_folder(new_project_path);
if project_type == Some(ProjectType::ShaderPack) {
let scope = resolve_content_scope(instance_id, None, state).await?;
let base = instance_full_path(state, &scope.instance);

let old_txt_path = base.join(format!(
"{}.txt",
old_project_path.trim_end_matches(".disabled")
));
let new_txt_path = base.join(format!(
"{}.txt",
new_project_path.trim_end_matches(".disabled")
));

if old_txt_path.exists() && !new_txt_path.exists() {
io::rename_or_move(&old_txt_path, &new_txt_path).await?;
}
}

Ok(())
}

pub(crate) async fn list_project_files(
instance_id: &str,
state: &State,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::collections::{HashMap, HashSet};
use super::apply_content_install::{
DownloadedProjectVersion, add_downloaded_project_version,
add_project_from_version, download_project_version, remove_project,
toggle_disable_project,
rename_project_companion_file, toggle_disable_project,
};
use super::check_content_updates::{ContentUpdate, check_content_updates};

Expand Down Expand Up @@ -108,6 +108,13 @@ async fn apply_content_update(
}

if new_path != project_path {
rename_project_companion_file(
instance_id,
project_path,
&new_path,
state,
)
.await?;
remove_project(instance_id, project_path, state).await?;
}

Expand Down Expand Up @@ -162,6 +169,13 @@ pub(crate) async fn update_all_projects(
}

if new_path != update.relative_path {
rename_project_companion_file(
instance_id,
&update.relative_path,
&new_path,
state,
)
.await?;
remove_project(instance_id, &update.relative_path, state)
.await?;
}
Expand Down