Get or compute the canonical project root path, using cache.
(&self)
| 118 | |
| 119 | /// Get or compute the canonical project root path, using cache. |
| 120 | fn get_canonical_project_root(&self) -> Result<PathBuf> { |
| 121 | let mut root_cache = self.canonical_project_root.borrow_mut(); |
| 122 | if let Some(ref root) = *root_cache { |
| 123 | return Ok(root.clone()); |
| 124 | } |
| 125 | |
| 126 | let root = self |
| 127 | .canonicalize_uncached(&self.project_root) |
| 128 | .with_context(|| { |
| 129 | format!( |
| 130 | "Failed to canonicalize project root: {}", |
| 131 | self.project_root.display() |
| 132 | ) |
| 133 | })?; |
| 134 | *root_cache = Some(root.clone()); |
| 135 | Ok(root) |
| 136 | } |
| 137 | |
| 138 | /// Validate that a path resolves within the project root and contains no traversal. |
| 139 | fn ensure_safe_path(&self, joined: &Path, display_path: &str) -> Result<PathBuf> { |
no test coverage detected