From b219774cb7b3bc1d0f9336815e50ef39911bb9e9 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Tue, 18 Jun 2024 20:42:04 +0300 Subject: [PATCH] add branch db --- ...kernel-cachy.json => db_kernel_cachy.json} | 0 data/kernel_branches.json | 8 +++ src/content/mod.rs | 54 ++++++------------- 3 files changed, 23 insertions(+), 39 deletions(-) rename data/{db-kernel-cachy.json => db_kernel_cachy.json} (100%) create mode 100644 data/kernel_branches.json diff --git a/data/db-kernel-cachy.json b/data/db_kernel_cachy.json similarity index 100% rename from data/db-kernel-cachy.json rename to data/db_kernel_cachy.json diff --git a/data/kernel_branches.json b/data/kernel_branches.json new file mode 100644 index 0000000..db9ded2 --- /dev/null +++ b/data/kernel_branches.json @@ -0,0 +1,8 @@ +{ + "branches": [ + { + "name": "kernel-cachyos", + "db": "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db_kernel_cachy.json" + } + ] +} \ No newline at end of file diff --git a/src/content/mod.rs b/src/content/mod.rs index 5628743..d7b1092 100644 --- a/src/content/mod.rs +++ b/src/content/mod.rs @@ -116,28 +116,6 @@ pub fn content(content_stack: >k::Stack, selected_kernel_branch: &Rc Vec { - let test_branch = KernelBranch { - name: "kernel-cachy".to_string(), - db: "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db-kernel-cachy.json".to_string() - }; + let mut kernel_branches_array: Vec = Vec::new(); + let data = fs::read_to_string( + "/home/ward/RustroverProjects/fedora-kernel-manager/data/kernel_branches.json", + ) + .expect("Unable to read file"); + let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse"); + if let serde_json::Value::Array(branches) = &res["branches"] { + for branch in branches { + let branch = KernelBranch{ + name: branch["name"].as_str().to_owned().unwrap().to_string(), + db: branch["db"].as_str().to_owned().unwrap().to_string(), + }; + kernel_branches_array.push(branch) + }}; - let test_branch2 = KernelBranch { - name: "kernel-tkg".to_string(), - db: "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db-kernel-cachy.json".to_string() - }; - - vec![test_branch, test_branch2] + kernel_branches_array } pub fn get_running_kernel_info() -> RunningKernelInfo { let kernel = match Command::new("uname")