(
requested_path: &str,
resolved_path: &Path,
is_runtime_artifact: bool,
)
| 182 | } |
| 183 | |
| 184 | pub fn stat_local_path_metadata( |
| 185 | requested_path: &str, |
| 186 | resolved_path: &Path, |
| 187 | is_runtime_artifact: bool, |
| 188 | ) -> Result<LocalFileMetadata, String> { |
| 189 | let metadata = std::fs::metadata(resolved_path).map_err(|e| { |
| 190 | format!( |
| 191 | "Failed to stat local file '{}': {}", |
| 192 | resolved_path.display(), |
| 193 | e |
| 194 | ) |
| 195 | })?; |
| 196 | |
| 197 | let modified = metadata |
| 198 | .modified() |
| 199 | .unwrap_or(SystemTime::UNIX_EPOCH) |
| 200 | .duration_since(SystemTime::UNIX_EPOCH) |
| 201 | .unwrap_or_default() |
| 202 | .as_millis() as u64; |
| 203 | |
| 204 | Ok(LocalFileMetadata { |
| 205 | path: requested_path.to_string(), |
| 206 | resolved_path: is_runtime_artifact.then(|| resolved_path.to_string_lossy().to_string()), |
| 207 | modified, |
| 208 | size: metadata.len(), |
| 209 | is_file: metadata.is_file(), |
| 210 | is_dir: metadata.is_dir(), |
| 211 | is_remote: Some(false), |
| 212 | is_runtime_artifact: is_runtime_artifact.then_some(true), |
| 213 | }) |
| 214 | } |
| 215 | |
| 216 | pub async fn read_text_file( |
| 217 | app_state: &AppState, |
no test coverage detected