mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-09 02:29:40 +00:00
Refactored metadata initialization (#441)
This commit is contained in:
1 parent
b0d4615506
commit
437ea2c243
2 files changed
+57
-38
No files matched your search
+43
-1
@@ -1,5 +1,5 @@
|
||||
use std::sync::Mutex;
|
||||
use once_cell::sync::Lazy;
|
||||
use std::sync::Mutex;
|
||||
|
||||
pub static META_DATA: Lazy<Mutex<Option<MetaData>>> = Lazy::new(|| Mutex::new(None));
|
||||
|
||||
@@ -15,4 +15,46 @@ pub struct MetaData {
|
||||
pub tauri_version: String,
|
||||
pub app_commit_hash: String,
|
||||
pub architecture: String,
|
||||
pub pdfium_version: String,
|
||||
}
|
||||
|
||||
impl MetaData {
|
||||
/// Creates a new instance of `MetaData` from the given metadata string.
|
||||
pub fn init_from_string(metadata: &str) -> Self {
|
||||
|
||||
// When the metadata is already initialized, return the existing instance:
|
||||
if let Some(metadata) = META_DATA.lock().unwrap().as_ref() {
|
||||
return metadata.clone();
|
||||
}
|
||||
|
||||
let mut metadata_lines = metadata.lines();
|
||||
let app_version = metadata_lines.next().unwrap();
|
||||
let build_time = metadata_lines.next().unwrap();
|
||||
let build_number = metadata_lines.next().unwrap();
|
||||
let dotnet_sdk_version = metadata_lines.next().unwrap();
|
||||
let dotnet_version = metadata_lines.next().unwrap();
|
||||
let rust_version = metadata_lines.next().unwrap();
|
||||
let mud_blazor_version = metadata_lines.next().unwrap();
|
||||
let tauri_version = metadata_lines.next().unwrap();
|
||||
let app_commit_hash = metadata_lines.next().unwrap();
|
||||
let architecture = metadata_lines.next().unwrap();
|
||||
let pdfium_version = metadata_lines.next().unwrap();
|
||||
|
||||
let metadata = MetaData {
|
||||
architecture: architecture.to_string(),
|
||||
app_commit_hash: app_commit_hash.to_string(),
|
||||
app_version: app_version.to_string(),
|
||||
build_number: build_number.to_string(),
|
||||
build_time: build_time.to_string(),
|
||||
dotnet_sdk_version: dotnet_sdk_version.to_string(),
|
||||
dotnet_version: dotnet_version.to_string(),
|
||||
mud_blazor_version: mud_blazor_version.to_string(),
|
||||
rust_version: rust_version.to_string(),
|
||||
tauri_version: tauri_version.to_string(),
|
||||
pdfium_version: pdfium_version.to_string(),
|
||||
};
|
||||
|
||||
*META_DATA.lock().unwrap() = Some(metadata.clone());
|
||||
metadata
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user