refactor: no delete the existing role/session when saving with a new name (#863)

pull/865/head
sigoden 1 month ago committed by GitHub
parent a9ea86f3f8
commit c821652ed9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -918,13 +918,7 @@ impl Config {
}
let role_path = Self::role_file(&role_name)?;
if let Some(role) = self.role.as_mut() {
let old_name = role.name().to_string();
role.save(&role_name, &role_path, self.working_mode.is_repl())?;
if old_name != role_name {
if let Ok(path) = Self::role_file(&old_name) {
let _ = remove_file(&path);
}
}
}
Ok(())
@ -1050,13 +1044,7 @@ impl Config {
};
let session_path = self.session_file(&session_name)?;
if let Some(session) = self.session.as_mut() {
let old_name = session.name().to_string();
session.save(&session_name, &session_path, self.working_mode.is_repl())?;
if old_name != session_name {
if let Ok(path) = self.session_file(&old_name) {
let _ = remove_file(&path);
}
}
}
Ok(())
}

Loading…
Cancel
Save