INNER CODE UNIT · Rust
writable
jub0t/Concat · src/crates/concat-api/src/lib.rs:243
fn writable(&self, path: &str) -> Result<(), ApiError> {
if self.roots.is_empty() {
return Ok(());
}
let outside = || {
let roots = self
.roots
.iter()
.map(|root| root.display().to_string())
.collect::<Vec<_>>()
.join(", ");
ApiError::new(
ErrorCode::Refused,
format!("{path} is outside where this API writes ({roots})"),
)
};
let given = Path::new(path);
// A `..` past the part of the path that exists cannot be resolved