From 19c7b59883922cd7622aeff75a84cdddba4ee736 Mon Sep 17 00:00:00 2001
From: GyDi <segydi@foxmail.com>
Date: Tue, 1 Mar 2022 11:05:33 +0800
Subject: [PATCH] feat: compatible profile config

---
 src-tauri/src/core/profiles.rs | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src-tauri/src/core/profiles.rs b/src-tauri/src/core/profiles.rs
index 0b872d7..da5ba86 100644
--- a/src-tauri/src/core/profiles.rs
+++ b/src-tauri/src/core/profiles.rs
@@ -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
-- 
GitLab