fix(config): delete legacy ~/.sunbeam.json after migration
The migration from ~/.sunbeam.json to ~/.sunbeam/config.json copied but never removed the legacy file, which could cause confusion with older binaries still writing to the old path.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use crate::error::{Result, ResultExt, SunbeamError};
|
use crate::error::{Result, ResultExt};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@@ -126,6 +126,7 @@ pub fn load_config() -> SunbeamConfig {
|
|||||||
let _ = std::fs::create_dir_all(parent);
|
let _ = std::fs::create_dir_all(parent);
|
||||||
}
|
}
|
||||||
if std::fs::copy(&legacy, &path).is_ok() {
|
if std::fs::copy(&legacy, &path).is_ok() {
|
||||||
|
let _ = std::fs::remove_file(&legacy);
|
||||||
crate::output::ok(&format!(
|
crate::output::ok(&format!(
|
||||||
"Migrated config: {} → {}",
|
"Migrated config: {} → {}",
|
||||||
legacy.display(),
|
legacy.display(),
|
||||||
@@ -176,7 +177,7 @@ pub fn load_config() -> SunbeamConfig {
|
|||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save configuration to ~/.sunbeam.json.
|
/// Save configuration to ~/.sunbeam/config.json.
|
||||||
pub fn save_config(config: &SunbeamConfig) -> Result<()> {
|
pub fn save_config(config: &SunbeamConfig) -> Result<()> {
|
||||||
let path = config_path();
|
let path = config_path();
|
||||||
if let Some(parent) = path.parent() {
|
if let Some(parent) = path.parent() {
|
||||||
|
|||||||
Reference in New Issue
Block a user