[roads] QA F-07: a missing roads/ folder is store.roads, and roads/ is never followed through a link

A store folder without roads/ compiled to plans with no access and no problem,
kill switches included. It is now an error naming roads. A roads/ that is a
file or a symbolic link is refused the same way (the builder's self-review #8):
entries inside were already refused, the folder itself was followed.
This commit is contained in:
2026-11-25 08:41:10 +01:00
parent 93ab087648
commit b6cf29b9a0
5 changed files with 55 additions and 3 deletions
+2
View File
@@ -8,6 +8,7 @@ pub const FILE_SIZE: &str = "file.size";
pub const FILE_ENCODING: &str = "file.encoding";
pub const FILE_HEADER: &str = "file.header";
pub const FILE_COUNT: &str = "file.count";
pub const STORE_ROADS: &str = "store.roads";
pub const YAML_REFUSED: &str = "yaml.refused";
pub const YAML_SYNTAX: &str = "yaml.syntax";
pub const KEY_UNKNOWN: &str = "key.unknown";
@@ -72,6 +73,7 @@ pub const ALL: &[&str] = &[
FILE_ENCODING,
FILE_HEADER,
FILE_COUNT,
STORE_ROADS,
YAML_REFUSED,
YAML_SYNTAX,
KEY_UNKNOWN,
+30 -1
View File
@@ -104,7 +104,36 @@ impl Store {
let mut files = Vec::new();
let mut problems = Vec::new();
let roads = root.join(ROADS_DIR);
if roads.is_dir() {
// A missing roads/ folder means no road grants anything, kill switches included: say so (QA F-07). The
// folder itself is never followed through a symbolic link, like the entries inside it.
let readable = match std::fs::symlink_metadata(&roads) {
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
problems.push(Problem::error(
ROADS_DIR,
None,
r::STORE_ROADS,
"missing: there is no roads/ folder, so no road grants anything and no kill switch is on",
));
false
}
Err(e) => return Err(e),
Ok(m) if !m.file_type().is_dir() => {
let what = if m.file_type().is_symlink() {
"a symbolic link"
} else {
"not a folder"
};
problems.push(Problem::error(
ROADS_DIR,
None,
r::STORE_ROADS,
format!("{what}; roads/ must be a real folder, so no road was read"),
));
false
}
Ok(_) => true,
};
if readable {
for entry in std::fs::read_dir(&roads)? {
let entry = entry?;
let name = entry.file_name().to_string_lossy().into_owned();