MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / write_registry_file

Function write_registry_file

packages/server/src/inspector.rs:572–589  ·  view source on GitHub ↗
(path: &Path, registry: &InspectorRegistryFile)

Source from the content-addressed store, hash-verified

570}
571
572fn 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
591fn prune_registry_file(registry: &mut InspectorRegistryFile) {
592 let cutoff = now_unix_ms().saturating_sub(INSPECTOR_REGISTRY_TTL.as_millis() as u64);

Callers 3

upsertMethod · 0.85
removeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected