Skip to content

Commit 31c2dc5

Browse files
authored
ignore files starting with . when loading folders (#11214)
# Objective - When loading a folder with dot files inside, Bevy crashes: ``` thread 'IO Task Pool (1)' panicked at crates/bevy_asset/src/io/mod.rs:260:10: asset paths must have extensions note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` - those files are common for other tools to store their settings/metadata ## Solution - Ignore files starting with a dot when loading folders
1 parent 235257f commit 31c2dc5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

crates/bevy_asset/src/io/file/file_asset.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ impl AssetReader for FileAssetReader {
7474
return None;
7575
}
7676
}
77+
// filter out hidden files. they are not listed by default but are directly targetable
78+
if path
79+
.file_name()
80+
.and_then(|file_name| file_name.to_str())
81+
.map(|file_name| file_name.starts_with('.'))
82+
.unwrap_or_default()
83+
{
84+
return None;
85+
}
7786
let relative_path = path.strip_prefix(&root_path).unwrap();
7887
Some(relative_path.to_owned())
7988
})

crates/bevy_asset/src/io/file/sync_file_asset.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ impl AssetReader for FileAssetReader {
145145
return None;
146146
}
147147
}
148+
// filter out hidden files. they are not listed by default but are directly targetable
149+
if path
150+
.file_name()
151+
.and_then(|file_name| file_name.to_str())
152+
.map(|file_name| file_name.starts_with('.'))
153+
.unwrap_or_default()
154+
{
155+
return None;
156+
}
157+
148158
let relative_path = path.strip_prefix(&root_path).unwrap();
149159
Some(relative_path.to_owned())
150160
})

0 commit comments

Comments
 (0)