fix: fetch profile panic

This commit is contained in:
GyDi 2022-02-17 13:44:26 +08:00 committed by GitHub
parent f709117cc4
commit c046a1993e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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