(
directory: &Path,
locks: &mut BTreeSet<PathBuf>,
)
| 1232 | } |
| 1233 | |
| 1234 | fn collect_top_level_locks( |
| 1235 | directory: &Path, |
| 1236 | locks: &mut BTreeSet<PathBuf>, |
| 1237 | ) -> Result<(), ObservationError> { |
| 1238 | let entries = match fs::read_dir(directory) { |
| 1239 | Ok(entries) => entries, |
| 1240 | Err(error) if error.kind() == io::ErrorKind::NotFound => return Ok(()), |
| 1241 | Err(error) => { |
| 1242 | return Err(ObservationError::new(format!( |
| 1243 | "cannot inspect Git administrative directory '{}': {error}", |
| 1244 | directory.display() |
| 1245 | ))); |
| 1246 | } |
| 1247 | }; |
| 1248 | for entry in entries { |
| 1249 | let entry = entry.map_err(|error| { |
| 1250 | ObservationError::new(format!( |
| 1251 | "cannot inspect entry under '{}': {error}", |
| 1252 | directory.display() |
| 1253 | )) |
| 1254 | })?; |
| 1255 | let path = entry.path(); |
| 1256 | if path.extension().and_then(|extension| extension.to_str()) == Some("lock") { |
| 1257 | locks.insert(path); |
| 1258 | } |
| 1259 | } |
| 1260 | Ok(()) |
| 1261 | } |
| 1262 | |
| 1263 | fn collect_locks_recursive( |
| 1264 | directory: &Path, |
no test coverage detected