From c046a1993e087b03bc93de28959dc577356e48c7 Mon Sep 17 00:00:00 2001
From: GyDi <segydi@foxmail.com>
Date: Thu, 17 Feb 2022 13:44:26 +0800
Subject: [PATCH] fix: fetch profile panic

---
 src-tauri/src/utils/fetch.rs | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src-tauri/src/utils/fetch.rs b/src-tauri/src/utils/fetch.rs
index 26fa135..a4031ef 100644
--- a/src-tauri/src/utils/fetch.rs
+++ b/src-tauri/src/utils/fetch.rs
@@ -54,20 +54,20 @@ pub async fn fetch_profile(url: &str, with_proxy: bool) -> Option<ProfileRespons
     }
   };
 
-  // parse the `name` and `file`
-  let (name, file) = {
+  let file = {
     let now = SystemTime::now()
       .duration_since(UNIX_EPOCH)
       .unwrap()
       .as_secs();
-    let file = format!("{}.yaml", now);
-    let name = header.get("Content-Disposition").unwrap().to_str().unwrap();
-    let name = parse_string::<String>(name, "filename=");
+    format!("{}.yaml", now)
+  };
 
-    match name {
-      Some(f) => (f, file),
-      None => (file.clone(), file),
+  let name = match header.get("Content-Disposition") {
+    Some(name) => {
+      let name = name.to_str().unwrap();
+      parse_string::<String>(name, "filename=").unwrap_or(file.clone())
     }
+    None => file.clone(),
   };
 
   // get the data
-- 
GitLab