MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / open

Method open

atomic-identity/src/store.rs:377–399  ·  view source on GitHub ↗

Open or create an identity store at the specified path.

(root: &Path)

Source from the content-addressed store, hash-verified

375
376 /// Open or create an identity store at the specified path.
377 pub fn open(root: &Path) -> Result<Self, IdentityError> {
378 // Create the directory if it doesn't exist
379 if !root.exists() {
380 fs::create_dir_all(root)?;
381 }
382
383 // Load or create configuration
384 let config_path = root.join(Self::CONFIG_FILE);
385 let config = if config_path.exists() {
386 let content = fs::read_to_string(&config_path)?;
387 toml::from_str(&content)?
388 } else {
389 let config = StoreConfig::new();
390 let content = toml::to_string_pretty(&config)?;
391 fs::write(&config_path, content)?;
392 config
393 };
394
395 Ok(Self {
396 root: root.to_path_buf(),
397 config,
398 })
399 }
400
401 /// Get the default store path.
402 ///

Callers 3

try_append_agent_traceFunction · 0.45
try_turn_end_lockMethod · 0.45

Calls 2

writeFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected