feat: compatible profile config

This commit is contained in:
GyDi 2022-03-01 11:05:33 +08:00 committed by GitHub
parent 749df89229
commit 19c7b59883
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -170,7 +170,21 @@ macro_rules! patch {
impl Profiles {
/// read the config from the file
pub fn read_file() -> Self {
config::read_yaml::<Self>(dirs::profiles_path())
let mut profiles = config::read_yaml::<Self>(dirs::profiles_path());
if profiles.items.is_none() {
profiles.items = Some(vec![]);
}
profiles.items.as_mut().map(|items| {
for mut item in items.iter_mut() {
if item.uid.is_none() {
item.uid = Some(help::get_uid("d"));
}
}
});
profiles
}
/// save the config to the file