MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / save

Method save

src/user_config.rs:168–189  ·  view source on GitHub ↗

Saves the user-level config file. Best-effort. Returns true if the file was saved, false on any error.

(&self)

Source from the content-addressed store, hash-verified

166 /// Saves the user-level config file. Best-effort.
167 /// Returns true if the file was saved, false on any error.
168 pub fn save(&self) -> bool {
169 let Some(path) = config_path() else {
170 return false;
171 };
172 if path.exists() {
173 let Ok(contents) = std::fs::read_to_string(&path) else {
174 return false;
175 };
176 if toml::from_str::<Self>(&contents).is_err() {
177 return false;
178 }
179 }
180 if let Some(parent) = path.parent() {
181 if std::fs::create_dir_all(parent).is_err() {
182 return false;
183 }
184 }
185 let Ok(contents) = toml::to_string_pretty(self) else {
186 return false;
187 };
188 std::fs::write(&path, contents).is_ok()
189 }
190
191 /// Saves only when the user-level config file already exists.
192 ///

Callers 11

run_silent_reinstallFunction · 0.45
handle_upload_counterFunction · 0.45
run_post_update_tasksFunction · 0.45
record_previous_versionFunction · 0.45
handle_install_commandFunction · 0.45
handle_reinstall_commandFunction · 0.45
handle_uninstall_commandFunction · 0.45
save_if_existsMethod · 0.45
benchmark_token_saviorFunction · 0.45

Calls 4

config_pathFunction · 0.85
writeFunction · 0.85
existsMethod · 0.80
is_okMethod · 0.80

Tested by

no test coverage detected