[mio] device_id获取不到时默认值取空

This commit is contained in:
lubeilin
2024-03-04 21:13:05 +08:00
parent 48b41c4b22
commit e7f2571469
+2 -2
View File
@@ -175,17 +175,17 @@ pub fn get_device_id() -> String {
if let Some(id) = common::identifier::get_unique_identifier() {
id
} else {
let id = uuid::Uuid::new_v4().to_string();
let path_buf = match crate::app_home() {
Ok(path_buf) => path_buf.join("device-id"),
Err(e) => {
log::warn!("{:?}", e);
return id;
return String::new();
}
};
if let Ok(id) = std::fs::read_to_string(path_buf.as_path()) {
id
} else {
let id = uuid::Uuid::new_v4().to_string();
let _ = std::fs::write(path_buf, &id);
id
}