Skip to content

Commit 7e769c7

Browse files
acorsicanfrogProspectorfetchfern
authored
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>
1 parent c1c86e3 commit 7e769c7

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

packages/app-lib/src/state/profiles.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,25 @@ struct InitialScanFile {
417417
cache_key: String,
418418
}
419419

420+
fn is_scannable_project_file(
421+
project_type: ProjectType,
422+
file_name: &str,
423+
) -> bool {
424+
let Some(extension) = Path::new(file_name.trim_end_matches(".disabled"))
425+
.extension()
426+
.and_then(|ext| ext.to_str())
427+
else {
428+
return false;
429+
};
430+
431+
match project_type {
432+
ProjectType::Mod => extension.eq_ignore_ascii_case("jar"),
433+
ProjectType::DataPack
434+
| ProjectType::ResourcePack
435+
| ProjectType::ShaderPack => extension.eq_ignore_ascii_case("zip"),
436+
}
437+
}
438+
420439
impl Profile {
421440
pub async fn get(
422441
path: &str,
@@ -648,8 +667,10 @@ impl Profile {
648667
&& let Some(file_name) = subdirectory
649668
.file_name()
650669
.and_then(|x| x.to_str())
651-
&& !(project_type == ProjectType::ShaderPack
652-
&& file_name.ends_with(".txt"))
670+
&& is_scannable_project_file(
671+
project_type,
672+
file_name,
673+
)
653674
{
654675
let file_size = subdirectory
655676
.metadata()
@@ -1052,8 +1073,7 @@ impl Profile {
10521073
if subdirectory.is_file()
10531074
&& let Some(file_name) =
10541075
subdirectory.file_name().and_then(|x| x.to_str())
1055-
&& !(project_type == ProjectType::ShaderPack
1056-
&& file_name.ends_with(".txt"))
1076+
&& is_scannable_project_file(project_type, file_name)
10571077
{
10581078
let file_size = subdirectory
10591079
.metadata()

0 commit comments

Comments
 (0)