Hide dotfiles from instance content scanning (#5999)

* 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. <fetch@ferrous.ch>
This commit is contained in:
Corsican Frog
2026-05-09 23:38:23 +02:00
committed by GitHub
parent c1c86e3b72
commit 7e769c720b

View File

@@ -417,6 +417,25 @@ struct InitialScanFile {
cache_key: String, 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 { impl Profile {
pub async fn get( pub async fn get(
path: &str, path: &str,
@@ -648,8 +667,10 @@ impl Profile {
&& let Some(file_name) = subdirectory && let Some(file_name) = subdirectory
.file_name() .file_name()
.and_then(|x| x.to_str()) .and_then(|x| x.to_str())
&& !(project_type == ProjectType::ShaderPack && is_scannable_project_file(
&& file_name.ends_with(".txt")) project_type,
file_name,
)
{ {
let file_size = subdirectory let file_size = subdirectory
.metadata() .metadata()
@@ -1052,8 +1073,7 @@ impl Profile {
if subdirectory.is_file() if subdirectory.is_file()
&& let Some(file_name) = && let Some(file_name) =
subdirectory.file_name().and_then(|x| x.to_str()) subdirectory.file_name().and_then(|x| x.to_str())
&& !(project_type == ProjectType::ShaderPack && is_scannable_project_file(project_type, file_name)
&& file_name.ends_with(".txt"))
{ {
let file_size = subdirectory let file_size = subdirectory
.metadata() .metadata()