From 49550ab3bd5b235608cf2eb0188e3a359dbbb415 Mon Sep 17 00:00:00 2001 From: Artezon Date: Sun, 28 Jun 2026 01:55:13 +0300 Subject: [PATCH 1/2] feat: rename shader settings sidecar file on version switch --- .../commands/apply_content_install.rs | 35 +++++++++++++++++++ .../commands/apply_content_update.rs | 16 ++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/packages/app-lib/src/state/instances/commands/apply_content_install.rs b/packages/app-lib/src/state/instances/commands/apply_content_install.rs index 0c780c7e76..a668be5e55 100644 --- a/packages/app-lib/src/state/instances/commands/apply_content_install.rs +++ b/packages/app-lib/src/state/instances/commands/apply_content_install.rs @@ -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?; } @@ -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, diff --git a/packages/app-lib/src/state/instances/commands/apply_content_update.rs b/packages/app-lib/src/state/instances/commands/apply_content_update.rs index e89d5b5378..09aa358921 100644 --- a/packages/app-lib/src/state/instances/commands/apply_content_update.rs +++ b/packages/app-lib/src/state/instances/commands/apply_content_update.rs @@ -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}; @@ -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?; } @@ -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?; } From db3a284d4e47cb831259811938591a0f6fe45720 Mon Sep 17 00:00:00 2001 From: "Calum H. (IMB11)" Date: Tue, 14 Jul 2026 10:27:39 +0100 Subject: [PATCH 2/2] fix: cleanup --- .../instances/commands/apply_content_install.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/app-lib/src/state/instances/commands/apply_content_install.rs b/packages/app-lib/src/state/instances/commands/apply_content_install.rs index a668be5e55..433dd03977 100644 --- a/packages/app-lib/src/state/instances/commands/apply_content_install.rs +++ b/packages/app-lib/src/state/instances/commands/apply_content_install.rs @@ -751,8 +751,16 @@ pub(crate) async fn rename_project_companion_file( 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?; + if old_txt_path.exists() { + if new_txt_path.exists() + && io::canonicalize(&old_txt_path)? + == io::canonicalize(&new_txt_path)? + { + return Ok(()); + } + + io::copy(&old_txt_path, &new_txt_path).await?; + io::remove_file(&old_txt_path).await?; } }