Remove if-not-else patterns (#10402)

This commit is contained in:
Joseph T. Lyons 2024-04-11 03:48:06 -04:00 committed by GitHub
parent 36a87d0f5c
commit eb6f7c1240
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 99 additions and 99 deletions

View file

@ -116,11 +116,7 @@ pub fn update_settings_file<T: Settings>(
store.new_text_for_update::<T>(old_text, update)
})?;
let initial_path = paths::SETTINGS.as_path();
if !fs.is_file(initial_path).await {
fs.atomic_write(initial_path.to_path_buf(), new_text)
.await
.with_context(|| format!("Failed to write settings to file {:?}", initial_path))?;
} else {
if fs.is_file(initial_path).await {
let resolved_path = fs.canonicalize(initial_path).await.with_context(|| {
format!("Failed to canonicalize settings path {:?}", initial_path)
})?;
@ -128,6 +124,10 @@ pub fn update_settings_file<T: Settings>(
fs.atomic_write(resolved_path.clone(), new_text)
.await
.with_context(|| format!("Failed to write settings to file {:?}", resolved_path))?;
} else {
fs.atomic_write(initial_path.to_path_buf(), new_text)
.await
.with_context(|| format!("Failed to write settings to file {:?}", initial_path))?;
}
anyhow::Ok(())