fix(autoconfigure): don't treat an empty BLS entries directory as BLS

BLS was detected when reading \loader\entries produced any item, but a
FAT directory always lists "." first, so an empty entries directory
counted as having entries. On an ESP with a leftover empty entries
directory, Linux autoconfiguration was skipped and no Linux entries
were shown. Only count the directory when it has a .conf file.
This commit is contained in:
alex authored and Alex Zenla committed 2026-09-26 20:52:15 -07:00
1 parent 133247c05a
commit b4e765279b
1 file changed
+14 -4
+14 -4
View File
@@ -46,12 +46,22 @@ pub fn scan(
.context("unable to check for BLS loader.conf file")?; .context("unable to check for BLS loader.conf file")?;
// Whether we have an entries directory. // Whether we have an entries directory.
// We actually iterate the entries to see if there are any. // We actually iterate the entries to see if there are any entry files, as the
// directory itself always has the "." and ".." items, even when it is empty.
let has_entries_dir = filesystem let has_entries_dir = filesystem
.read_dir(bls_entries_path) .read_dir(bls_entries_path)
.ok() .map(|mut iterator| {
.and_then(|mut iterator| iterator.next()) iterator.any(|entry| {
.map(|entry| entry.is_ok()) entry.is_ok_and(|entry| {
entry.is_regular_file()
&& entry
.file_name()
.to_string()
.to_lowercase()
.ends_with(".conf")
})
})
})
.unwrap_or(false); .unwrap_or(false);
// Detect if a BLS supported configuration is on this filesystem. // Detect if a BLS supported configuration is on this filesystem.