From 7e769c720bfabe563eefc6a1dd0f7d3006ba4f37 Mon Sep 17 00:00:00 2001 From: Corsican Frog <49497194+acorsicanfrog@users.noreply.github.com> Date: Sat, 9 May 2026 23:38:23 +0200 Subject: [PATCH] Hide dotfiles from instance content scanning (#5999) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Hide dotfiles from instance content scanning Prevent hidden files such as .DS_Store from being treated as valid instance content. This updates the profile scanning logic in [packages/app-lib/src/state/profiles.rs](/Users/froggy/Downloads/code-main/packages/app-lib/src/state/profiles.rs#L420) to ignore basenames that start with '.', and applies that filter consistently in both scan paths. Signed-off-by: Corsican Frog <49497194+acorsicanfrog@users.noreply.github.com> * Whitelist scannable instance content files Only scan supported content archives into instance content. Accept .jar files for mods and .zip files for datapacks, resourcepacks, and shaderpacks, after trimming the .disabled suffix. This prevents .DS_Store and other unsupported files from appearing in the Content tab. Signed-off-by: Corsican Frog <49497194+acorsicanfrog@users.noreply.github.com> * Fmt --------- Signed-off-by: Corsican Frog <49497194+acorsicanfrog@users.noreply.github.com> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com> Co-authored-by: François-X. T. --- packages/app-lib/src/state/profiles.rs | 28 ++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/app-lib/src/state/profiles.rs b/packages/app-lib/src/state/profiles.rs index da8912755..761df2d8b 100644 --- a/packages/app-lib/src/state/profiles.rs +++ b/packages/app-lib/src/state/profiles.rs @@ -417,6 +417,25 @@ struct InitialScanFile { cache_key: String, } +fn is_scannable_project_file( + project_type: ProjectType, + file_name: &str, +) -> bool { + let Some(extension) = Path::new(file_name.trim_end_matches(".disabled")) + .extension() + .and_then(|ext| ext.to_str()) + else { + return false; + }; + + match project_type { + ProjectType::Mod => extension.eq_ignore_ascii_case("jar"), + ProjectType::DataPack + | ProjectType::ResourcePack + | ProjectType::ShaderPack => extension.eq_ignore_ascii_case("zip"), + } +} + impl Profile { pub async fn get( path: &str, @@ -648,8 +667,10 @@ impl Profile { && let Some(file_name) = subdirectory .file_name() .and_then(|x| x.to_str()) - && !(project_type == ProjectType::ShaderPack - && file_name.ends_with(".txt")) + && is_scannable_project_file( + project_type, + file_name, + ) { let file_size = subdirectory .metadata() @@ -1052,8 +1073,7 @@ impl Profile { if subdirectory.is_file() && let Some(file_name) = subdirectory.file_name().and_then(|x| x.to_str()) - && !(project_type == ProjectType::ShaderPack - && file_name.ends_with(".txt")) + && is_scannable_project_file(project_type, file_name) { let file_size = subdirectory .metadata()