[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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user