(path: &Path, registry: &InspectorRegistryFile)
| 570 | } |
| 571 | |
| 572 | fn write_registry_file(path: &Path, registry: &InspectorRegistryFile) -> io::Result<()> { |
| 573 | if let Some(parent) = path.parent() { |
| 574 | fs::create_dir_all(parent)?; |
| 575 | } |
| 576 | let temporary_path = path.with_extension(format!( |
| 577 | "json.{}.{}.tmp", |
| 578 | process::id(), |
| 579 | REGISTRY_TEMP_COUNTER.fetch_add(1, Ordering::Relaxed) |
| 580 | )); |
| 581 | let data = serde_json::to_vec_pretty(registry).map_err(io::Error::other)?; |
| 582 | fs::write(&temporary_path, data)?; |
| 583 | #[cfg(unix)] |
| 584 | { |
| 585 | use std::os::unix::fs::PermissionsExt; |
| 586 | let _ = fs::set_permissions(&temporary_path, fs::Permissions::from_mode(0o600)); |
| 587 | } |
| 588 | fs::rename(temporary_path, path) |
| 589 | } |
| 590 | |
| 591 | fn prune_registry_file(registry: &mut InspectorRegistryFile) { |
| 592 | let cutoff = now_unix_ms().saturating_sub(INSPECTOR_REGISTRY_TTL.as_millis() as u64); |
no outgoing calls
no test coverage detected