MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / save

Method save

crates/cli/src/config.rs:724–745  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

722 }
723
724 pub fn save(&self) {
725 let home_path = &self.home_path;
726 // If the `home_path` is in a directory, ensure it exists.
727 home_path.create_parent().unwrap();
728
729 let config = self.doc().to_string();
730
731 eprintln!("Saving config to {}.", home_path.display());
732 // TODO: We currently have a race condition if multiple processes are modifying the config.
733 // If process X and process Y read the config, each make independent changes, and then save
734 // the config, the first writer will have its changes clobbered by the second writer.
735 //
736 // We used to use `Lockfile` to prevent this from happening, but we had other issues with
737 // that approach (see https://github.com/clockworklabs/SpacetimeDB/issues/1339, and the
738 // TODO in `lockfile.rs`).
739 //
740 // We should address this issue, but we currently don't expect it to arise very frequently
741 // (see https://github.com/clockworklabs/SpacetimeDB/pull/1341#issuecomment-2150857432).
742 if let Err(e) = atomic_write(&home_path.0, config) {
743 eprintln!("Could not save config file: {e}")
744 }
745 }
746
747 pub fn server_decoding_key(&self, server: Option<&str>) -> anyhow::Result<DecodingKey> {
748 self.server_fingerprint(server).and_then(|fing| {

Callers 15

on_connectedFunction · 0.45
on_connectedFunction · 0.45
loadMethod · 0.45
check_configFunction · 0.45
test_config_concurrentFunction · 0.45
exec_set_defaultFunction · 0.45
exec_addFunction · 0.45
exec_removeFunction · 0.45
exec_fingerprintFunction · 0.45
exec_editFunction · 0.45
ensure_logged_outFunction · 0.45

Calls 5

atomic_writeFunction · 0.85
create_parentMethod · 0.80
docMethod · 0.80
unwrapMethod · 0.45
to_stringMethod · 0.45

Tested by 1

test_config_concurrentFunction · 0.36