fix config corruption crash
This commit is contained in:
parent
8109f2db5e
commit
632dca0f46
@ -77,7 +77,12 @@ pub fn build_ui(app: &adw::Application) {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
content_stack.add_named(
|
content_stack.add_named(
|
||||||
&content::content(&content_stack, &selected_kernel_branch2, &db_load_complete, &window),
|
&content::content(
|
||||||
|
&content_stack,
|
||||||
|
&selected_kernel_branch2,
|
||||||
|
&db_load_complete,
|
||||||
|
&window,
|
||||||
|
),
|
||||||
Some("content_page"),
|
Some("content_page"),
|
||||||
);
|
);
|
||||||
content_stack.add_named(
|
content_stack.add_named(
|
||||||
|
@ -9,10 +9,10 @@ use gtk::prelude::*;
|
|||||||
use gtk::*;
|
use gtk::*;
|
||||||
use homedir::get_my_home;
|
use homedir::get_my_home;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::{fs, time};
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use std::{fs, time};
|
||||||
use version_compare::Version;
|
use version_compare::Version;
|
||||||
use Vec;
|
use Vec;
|
||||||
|
|
||||||
@ -128,13 +128,15 @@ pub fn content(
|
|||||||
.build();
|
.build();
|
||||||
browse_kernels_button.add_css_class("circular");
|
browse_kernels_button.add_css_class("circular");
|
||||||
|
|
||||||
browse_kernels_button.connect_clicked(clone!(@weak window, @weak content_stack, @strong selected_kernel_branch => move |_| {
|
browse_kernels_button.connect_clicked(
|
||||||
|
clone!(@weak window, @weak content_stack, @strong selected_kernel_branch => move |_| {
|
||||||
content_stack.add_named(
|
content_stack.add_named(
|
||||||
&kernel_pkg::kernel_pkg_page(&content_stack, &window, &selected_kernel_branch),
|
&kernel_pkg::kernel_pkg_page(&content_stack, &window, &selected_kernel_branch),
|
||||||
Some("kernel_pkg_page"),
|
Some("kernel_pkg_page"),
|
||||||
);
|
);
|
||||||
content_stack.set_visible_child_name("kernel_pkg_page")
|
content_stack.set_visible_child_name("kernel_pkg_page")
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
let config_kernel_button = gtk::Button::builder()
|
let config_kernel_button = gtk::Button::builder()
|
||||||
.icon_name("settings")
|
.icon_name("settings")
|
||||||
@ -164,7 +166,6 @@ pub fn content(
|
|||||||
content_box.append(&kernel_branch_expander_row_boxedlist);
|
content_box.append(&kernel_branch_expander_row_boxedlist);
|
||||||
content_box.append(&button_box);
|
content_box.append(&button_box);
|
||||||
|
|
||||||
|
|
||||||
let (load_badge_async_sender, load_badge_async_receiver) = async_channel::unbounded();
|
let (load_badge_async_sender, load_badge_async_receiver) = async_channel::unbounded();
|
||||||
let load_badge_async_sender = load_badge_async_sender.clone();
|
let load_badge_async_sender = load_badge_async_sender.clone();
|
||||||
// The long running operation runs now in a separate thread
|
// The long running operation runs now in a separate thread
|
||||||
@ -243,24 +244,12 @@ for branch in data {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
match get_my_home()
|
match get_my_home().unwrap().unwrap().join(".config/fedora-kernel-manager/branch").exists() {
|
||||||
.unwrap()
|
true if fs::read_to_string(get_my_home().unwrap().unwrap().join(".config/fedora-kernel-manager/branch")).unwrap()== branch_clone1.name && std::fs::metadata(get_my_home().unwrap().unwrap().join(".config/fedora-kernel-manager/branch")).expect("file metadata not found").len() == 0 =>
|
||||||
.unwrap()
|
|
||||||
.join(".config/fedora-kernel-manager/branch")
|
|
||||||
.exists()
|
|
||||||
{
|
|
||||||
true if fs::read_to_string(
|
|
||||||
get_my_home()
|
|
||||||
.unwrap()
|
|
||||||
.unwrap()
|
|
||||||
.join(".config/fedora-kernel-manager/branch"),
|
|
||||||
)
|
|
||||||
.unwrap()
|
|
||||||
== branch_clone1.name =>
|
|
||||||
{
|
{
|
||||||
branch_checkbutton.set_active(true)
|
branch_checkbutton.set_active(true)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => branch_container.first_child().unwrap().property::<gtk::CheckButton>("activatable_widget").set_property("active", true),
|
||||||
};
|
};
|
||||||
|
|
||||||
*db_load_complete.borrow_mut() = true;
|
*db_load_complete.borrow_mut() = true;
|
||||||
@ -450,18 +439,24 @@ fn bore_check() -> bool {
|
|||||||
is_bore
|
is_bore
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_kernel_badges(badge_box: >k::Box, running_kernel_info: &RunningKernelInfo, selected_kernel_branch: &Rc<RefCell<KernelBranch>>) {
|
fn create_kernel_badges(
|
||||||
|
badge_box: >k::Box,
|
||||||
|
running_kernel_info: &RunningKernelInfo,
|
||||||
|
selected_kernel_branch: &Rc<RefCell<KernelBranch>>,
|
||||||
|
) {
|
||||||
let selected_kernel_branch_clone = selected_kernel_branch.borrow().clone();
|
let selected_kernel_branch_clone = selected_kernel_branch.borrow().clone();
|
||||||
|
|
||||||
let kernel_badges_size_group = gtk::SizeGroup::new(SizeGroupMode::Both);
|
let kernel_badges_size_group = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||||
let kernel_badges_size_group0 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
let kernel_badges_size_group0 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||||
let kernel_badges_size_group1 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
let kernel_badges_size_group1 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||||
|
|
||||||
let json: serde_json::Value = serde_json::from_str(&selected_kernel_branch_clone.db).expect("Unable to parse");
|
dbg!(&selected_kernel_branch_clone.db);
|
||||||
|
let json: serde_json::Value =
|
||||||
|
serde_json::from_str(&selected_kernel_branch_clone.db).expect("Unable to parse");
|
||||||
|
|
||||||
let kernel_version = match json["latest_version"].as_str() {
|
let kernel_version = match json["latest_version"].as_str() {
|
||||||
Some(t) => t,
|
Some(t) => t,
|
||||||
_ => "Unknown"
|
_ => "Unknown",
|
||||||
};
|
};
|
||||||
|
|
||||||
let version_css_style = if &running_kernel_info.version == &kernel_version {
|
let version_css_style = if &running_kernel_info.version == &kernel_version {
|
||||||
|
@ -1,21 +1,25 @@
|
|||||||
use std::io::BufReader;
|
|
||||||
use duct::cmd;
|
|
||||||
use std::process::Command;
|
|
||||||
use std::cell::RefCell;
|
|
||||||
use crate::content::get_running_kernel_info;
|
use crate::content::get_running_kernel_info;
|
||||||
use crate::{KernelBranch, RunningKernelInfo};
|
use crate::{KernelBranch, RunningKernelInfo};
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
|
use duct::cmd;
|
||||||
use glib::*;
|
use glib::*;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::*;
|
use gtk::*;
|
||||||
|
use std::cell::RefCell;
|
||||||
|
use std::error::Error;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::*;
|
use std::fs::*;
|
||||||
|
use std::io::BufRead;
|
||||||
|
use std::io::BufReader;
|
||||||
|
use std::process::Command;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::time::*;
|
use std::time::*;
|
||||||
use std::error::Error;
|
|
||||||
use std::io::BufRead;
|
|
||||||
|
|
||||||
pub fn kernel_pkg_page(content_stack: >k::Stack, window: &adw::ApplicationWindow, selected_kernel_branch: &Rc<RefCell<KernelBranch>>) -> gtk::Box {
|
pub fn kernel_pkg_page(
|
||||||
|
content_stack: >k::Stack,
|
||||||
|
window: &adw::ApplicationWindow,
|
||||||
|
selected_kernel_branch: &Rc<RefCell<KernelBranch>>,
|
||||||
|
) -> gtk::Box {
|
||||||
let selected_kernel_branch_clone0 = selected_kernel_branch.borrow().clone();
|
let selected_kernel_branch_clone0 = selected_kernel_branch.borrow().clone();
|
||||||
|
|
||||||
let main_box = gtk::Box::builder()
|
let main_box = gtk::Box::builder()
|
||||||
@ -25,7 +29,10 @@ pub fn kernel_pkg_page(content_stack: >k::Stack, window: &adw::ApplicationWind
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
let main_label = gtk::Label::builder()
|
let main_label = gtk::Label::builder()
|
||||||
.label(format!("Available Kernel Packages for {}", &selected_kernel_branch_clone0.name))
|
.label(format!(
|
||||||
|
"Available Kernel Packages for {}",
|
||||||
|
&selected_kernel_branch_clone0.name
|
||||||
|
))
|
||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
.margin_start(10)
|
.margin_start(10)
|
||||||
.margin_end(10)
|
.margin_end(10)
|
||||||
@ -49,7 +56,12 @@ pub fn kernel_pkg_page(content_stack: >k::Stack, window: &adw::ApplicationWind
|
|||||||
.build();
|
.build();
|
||||||
packages_boxedlist.add_css_class("boxed-list");
|
packages_boxedlist.add_css_class("boxed-list");
|
||||||
let rows_size_group = gtk::SizeGroup::new(SizeGroupMode::Both);
|
let rows_size_group = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||||
add_package_rows(&packages_boxedlist, &selected_kernel_branch_clone0.db, &window, &rows_size_group);
|
add_package_rows(
|
||||||
|
&packages_boxedlist,
|
||||||
|
&selected_kernel_branch_clone0.db,
|
||||||
|
&window,
|
||||||
|
&rows_size_group,
|
||||||
|
);
|
||||||
|
|
||||||
let packages_viewport = gtk::ScrolledWindow::builder()
|
let packages_viewport = gtk::ScrolledWindow::builder()
|
||||||
.hscrollbar_policy(PolicyType::Never)
|
.hscrollbar_policy(PolicyType::Never)
|
||||||
@ -96,7 +108,8 @@ pub fn kernel_pkg_page(content_stack: >k::Stack, window: &adw::ApplicationWind
|
|||||||
main_box
|
main_box
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_package_rows(boxedlist: >k::ListBox,
|
fn add_package_rows(
|
||||||
|
boxedlist: >k::ListBox,
|
||||||
data: &str,
|
data: &str,
|
||||||
window: &adw::ApplicationWindow,
|
window: &adw::ApplicationWindow,
|
||||||
rows_size_group: >k::SizeGroup,
|
rows_size_group: >k::SizeGroup,
|
||||||
@ -106,7 +119,11 @@ fn add_package_rows(boxedlist: >k::ListBox,
|
|||||||
for kernel in kernels {
|
for kernel in kernels {
|
||||||
let kernel_name = kernel["name"].as_str().to_owned().unwrap().to_string();
|
let kernel_name = kernel["name"].as_str().to_owned().unwrap().to_string();
|
||||||
let kernel_package = kernel["package"].as_str().to_owned().unwrap().to_string();
|
let kernel_package = kernel["package"].as_str().to_owned().unwrap().to_string();
|
||||||
let kernel_description = kernel["description"].as_str().to_owned().unwrap().to_string();
|
let kernel_description = kernel["description"]
|
||||||
|
.as_str()
|
||||||
|
.to_owned()
|
||||||
|
.unwrap()
|
||||||
|
.to_string();
|
||||||
|
|
||||||
let (log_loop_sender, log_loop_receiver) = async_channel::unbounded();
|
let (log_loop_sender, log_loop_receiver) = async_channel::unbounded();
|
||||||
let log_loop_sender: async_channel::Sender<String> = log_loop_sender.clone();
|
let log_loop_sender: async_channel::Sender<String> = log_loop_sender.clone();
|
||||||
@ -115,7 +132,8 @@ fn add_package_rows(boxedlist: >k::ListBox,
|
|||||||
let log_status_loop_sender: async_channel::Sender<bool> =
|
let log_status_loop_sender: async_channel::Sender<bool> =
|
||||||
log_status_loop_sender.clone();
|
log_status_loop_sender.clone();
|
||||||
|
|
||||||
let (kernel_status_loop_sender, kernel_status_loop_receiver) = async_channel::unbounded();
|
let (kernel_status_loop_sender, kernel_status_loop_receiver) =
|
||||||
|
async_channel::unbounded();
|
||||||
let kernel_status_loop_sender: async_channel::Sender<bool> =
|
let kernel_status_loop_sender: async_channel::Sender<bool> =
|
||||||
kernel_status_loop_sender.clone();
|
kernel_status_loop_sender.clone();
|
||||||
|
|
||||||
@ -130,22 +148,20 @@ fn add_package_rows(boxedlist: >k::ListBox,
|
|||||||
// kernel_status_loop_sender.send_blocking(false).expect("channel needs to be open")
|
// kernel_status_loop_sender.send_blocking(false).expect("channel needs to be open")
|
||||||
//}
|
//}
|
||||||
std::thread::sleep(Duration::from_secs(6));
|
std::thread::sleep(Duration::from_secs(6));
|
||||||
kernel_status_loop_sender.send_blocking(true).expect("channel needs to be open")
|
kernel_status_loop_sender
|
||||||
|
.send_blocking(true)
|
||||||
|
.expect("channel needs to be open")
|
||||||
});
|
});
|
||||||
|
|
||||||
let kernel_expander_row = adw::ExpanderRow::new();
|
let kernel_expander_row = adw::ExpanderRow::new();
|
||||||
let kernel_package_label = gtk::Label::builder()
|
let kernel_package_label = gtk::Label::builder().label(&kernel_package).build();
|
||||||
.label(&kernel_package)
|
|
||||||
.build();
|
|
||||||
let kernel_status_icon = gtk::Image::builder()
|
let kernel_status_icon = gtk::Image::builder()
|
||||||
.icon_name("emblem-default")
|
.icon_name("emblem-default")
|
||||||
.pixel_size(24)
|
.pixel_size(24)
|
||||||
.visible(false)
|
.visible(false)
|
||||||
.tooltip_text("Installed")
|
.tooltip_text("Installed")
|
||||||
.build();
|
.build();
|
||||||
let kernel_description_label = gtk::Label::builder()
|
let kernel_description_label = gtk::Label::builder().label(&kernel_description).build();
|
||||||
.label(&kernel_description)
|
|
||||||
.build();
|
|
||||||
let kernel_content_row = adw::ActionRow::builder().build();
|
let kernel_content_row = adw::ActionRow::builder().build();
|
||||||
let kernel_install_button = gtk::Button::builder()
|
let kernel_install_button = gtk::Button::builder()
|
||||||
.margin_start(5)
|
.margin_start(5)
|
||||||
@ -221,14 +237,9 @@ fn add_package_rows(boxedlist: >k::ListBox,
|
|||||||
.height_request(200)
|
.height_request(200)
|
||||||
.heading("Installing Kernel")
|
.heading("Installing Kernel")
|
||||||
.build();
|
.build();
|
||||||
kernel_install_dialog.add_response(
|
kernel_install_dialog.add_response("kernel_install_dialog_ok", "OK");
|
||||||
"kernel_install_dialog_ok",
|
kernel_install_dialog
|
||||||
"OK",
|
.add_response("kernel_install_dialog_reboot", "Reboot Now (Optional)");
|
||||||
);
|
|
||||||
kernel_install_dialog.add_response(
|
|
||||||
"kernel_install_dialog_reboot",
|
|
||||||
"Reboot Now (Optional)",
|
|
||||||
);
|
|
||||||
kernel_install_dialog.set_response_appearance(
|
kernel_install_dialog.set_response_appearance(
|
||||||
"kernel_install_dialog_reboot",
|
"kernel_install_dialog_reboot",
|
||||||
adw::ResponseAppearance::Suggested,
|
adw::ResponseAppearance::Suggested,
|
||||||
@ -333,7 +344,8 @@ fn add_package_rows(boxedlist: >k::ListBox,
|
|||||||
}));
|
}));
|
||||||
//
|
//
|
||||||
boxedlist.append(&kernel_expander_row);
|
boxedlist.append(&kernel_expander_row);
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const KERNEL_MODIFY_PROG: &str = r###"
|
const KERNEL_MODIFY_PROG: &str = r###"
|
||||||
|
Loading…
Reference in New Issue
Block a user