fix some race conds
This commit is contained in:
parent
a1ec14ed42
commit
e4a605915d
@ -1,4 +1,4 @@
|
|||||||
use std::{cell::{RefCell}, rc::Rc, sync::OnceLock};
|
use std::{cell::RefCell, rc::Rc, sync::OnceLock};
|
||||||
|
|
||||||
use adw::{prelude::*, subclass::prelude::*, *};
|
use adw::{prelude::*, subclass::prelude::*, *};
|
||||||
use glib::{clone, subclass::Signal, Properties};
|
use glib::{clone, subclass::Signal, Properties};
|
||||||
|
@ -26,6 +26,7 @@ impl DriveMountRow {
|
|||||||
partition: create_parition_struct(&self.partition()),
|
partition: create_parition_struct(&self.partition()),
|
||||||
mountpoint: self.mountpoint(),
|
mountpoint: self.mountpoint(),
|
||||||
mountopts: self.mountopts(),
|
mountopts: self.mountopts(),
|
||||||
|
used_by: self.id(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,9 +216,10 @@ pub fn create_efi_row(
|
|||||||
} else {
|
} else {
|
||||||
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| x != &row.partition());
|
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| x != &row.partition());
|
||||||
}
|
}
|
||||||
partition_changed_action.activate(Some(
|
partition_changed_action.activate(Some(&glib::variant::Variant::from_data_with_type(
|
||||||
&glib::variant::Variant::from_data_with_type(row.id().to_string(), glib::VariantTy::STRING)
|
row.id().to_string(),
|
||||||
));
|
glib::VariantTy::STRING,
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -241,7 +242,10 @@ pub fn create_efi_row(
|
|||||||
(*used_partition_array_refcell.borrow_mut())
|
(*used_partition_array_refcell.borrow_mut())
|
||||||
.retain(|x| &x.partition.part_name != &row.partition());
|
.retain(|x| &x.partition.part_name != &row.partition());
|
||||||
partition_changed_action.activate(Some(
|
partition_changed_action.activate(Some(
|
||||||
&glib::variant::Variant::from_data_with_type(row.id().to_string(), glib::VariantTy::STRING)
|
&glib::variant::Variant::from_data_with_type(
|
||||||
|
row.id().to_string(),
|
||||||
|
glib::VariantTy::STRING,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -282,7 +286,6 @@ pub fn create_boot_row(
|
|||||||
|
|
||||||
let null_checkbutton = gtk::CheckButton::builder().build();
|
let null_checkbutton = gtk::CheckButton::builder().build();
|
||||||
|
|
||||||
|
|
||||||
for partition in partition_array {
|
for partition in partition_array {
|
||||||
let part_name = &partition.part_name.to_owned();
|
let part_name = &partition.part_name.to_owned();
|
||||||
let partition_button = gtk::CheckButton::builder()
|
let partition_button = gtk::CheckButton::builder()
|
||||||
@ -445,9 +448,10 @@ pub fn create_boot_row(
|
|||||||
} else {
|
} else {
|
||||||
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| x != &row.partition());
|
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| x != &row.partition());
|
||||||
}
|
}
|
||||||
partition_changed_action.activate(Some(
|
partition_changed_action.activate(Some(&glib::variant::Variant::from_data_with_type(
|
||||||
&glib::variant::Variant::from_data_with_type(row.id().to_string(), glib::VariantTy::STRING)
|
row.id().to_string(),
|
||||||
));
|
glib::VariantTy::STRING,
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -470,7 +474,10 @@ pub fn create_boot_row(
|
|||||||
(*used_partition_array_refcell.borrow_mut())
|
(*used_partition_array_refcell.borrow_mut())
|
||||||
.retain(|x| &x.partition.part_name != &row.partition());
|
.retain(|x| &x.partition.part_name != &row.partition());
|
||||||
partition_changed_action.activate(Some(
|
partition_changed_action.activate(Some(
|
||||||
&glib::variant::Variant::from_data_with_type(row.id().to_string(), glib::VariantTy::STRING)
|
&glib::variant::Variant::from_data_with_type(
|
||||||
|
row.id().to_string(),
|
||||||
|
glib::VariantTy::STRING,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -511,7 +518,6 @@ pub fn create_root_row(
|
|||||||
|
|
||||||
let null_checkbutton = gtk::CheckButton::builder().build();
|
let null_checkbutton = gtk::CheckButton::builder().build();
|
||||||
|
|
||||||
|
|
||||||
for partition in partition_array {
|
for partition in partition_array {
|
||||||
let part_name = &partition.part_name.to_owned();
|
let part_name = &partition.part_name.to_owned();
|
||||||
let partition_button = gtk::CheckButton::builder()
|
let partition_button = gtk::CheckButton::builder()
|
||||||
@ -679,9 +685,10 @@ pub fn create_root_row(
|
|||||||
} else {
|
} else {
|
||||||
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| x != &row.partition());
|
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| x != &row.partition());
|
||||||
}
|
}
|
||||||
partition_changed_action.activate(Some(
|
partition_changed_action.activate(Some(&glib::variant::Variant::from_data_with_type(
|
||||||
&glib::variant::Variant::from_data_with_type(row.id().to_string(), glib::VariantTy::STRING)
|
row.id().to_string(),
|
||||||
));
|
glib::VariantTy::STRING,
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -704,7 +711,10 @@ pub fn create_root_row(
|
|||||||
(*used_partition_array_refcell.borrow_mut())
|
(*used_partition_array_refcell.borrow_mut())
|
||||||
.retain(|x| &x.partition.part_name != &row.partition());
|
.retain(|x| &x.partition.part_name != &row.partition());
|
||||||
partition_changed_action.activate(Some(
|
partition_changed_action.activate(Some(
|
||||||
&glib::variant::Variant::from_data_with_type(row.id().to_string(), glib::VariantTy::STRING)
|
&glib::variant::Variant::from_data_with_type(
|
||||||
|
row.id().to_string(),
|
||||||
|
glib::VariantTy::STRING,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -746,7 +756,6 @@ pub fn create_mount_row(
|
|||||||
|
|
||||||
let null_checkbutton = gtk::CheckButton::builder().build();
|
let null_checkbutton = gtk::CheckButton::builder().build();
|
||||||
|
|
||||||
|
|
||||||
for partition in partition_array {
|
for partition in partition_array {
|
||||||
let part_name = &partition.part_name.to_owned();
|
let part_name = &partition.part_name.to_owned();
|
||||||
let partition_button = gtk::CheckButton::builder()
|
let partition_button = gtk::CheckButton::builder()
|
||||||
@ -877,9 +886,10 @@ pub fn create_mount_row(
|
|||||||
} else {
|
} else {
|
||||||
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| x != &row.partition());
|
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| x != &row.partition());
|
||||||
}
|
}
|
||||||
partition_changed_action.activate(Some(
|
partition_changed_action.activate(Some(&glib::variant::Variant::from_data_with_type(
|
||||||
&glib::variant::Variant::from_data_with_type(row.id().to_string(), glib::VariantTy::STRING)
|
row.id().to_string(),
|
||||||
));
|
glib::VariantTy::STRING,
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -902,7 +912,10 @@ pub fn create_mount_row(
|
|||||||
(*used_partition_array_refcell.borrow_mut())
|
(*used_partition_array_refcell.borrow_mut())
|
||||||
.retain(|x| &x.partition.part_name != &row.partition());
|
.retain(|x| &x.partition.part_name != &row.partition());
|
||||||
partition_changed_action.activate(Some(
|
partition_changed_action.activate(Some(
|
||||||
&glib::variant::Variant::from_data_with_type(row.id().to_string(), glib::VariantTy::STRING)
|
&glib::variant::Variant::from_data_with_type(
|
||||||
|
row.id().to_string(),
|
||||||
|
glib::VariantTy::STRING,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -966,14 +979,23 @@ fn post_check_drive_mount(
|
|||||||
if partition_button.is_active() == true {
|
if partition_button.is_active() == true {
|
||||||
let part_name = &partition.part_name;
|
let part_name = &partition.part_name;
|
||||||
row.set_partition(part_name.to_string());
|
row.set_partition(part_name.to_string());
|
||||||
|
if !used_partition_array_refcell
|
||||||
|
.borrow()
|
||||||
|
.iter()
|
||||||
|
.any(|e| part_name == &e.partition.part_name)
|
||||||
|
{
|
||||||
(*used_partition_array_refcell.borrow_mut())
|
(*used_partition_array_refcell.borrow_mut())
|
||||||
.push(DriveMountRow::get_fstab_entry(&row));
|
.push(DriveMountRow::get_fstab_entry(&row));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(*used_partition_array_refcell.borrow_mut())
|
(*used_partition_array_refcell.borrow_mut())
|
||||||
.retain(|x| &x.partition.part_name != &row.partition());
|
.retain(|x| &x.partition.part_name != &row.partition());
|
||||||
}
|
}
|
||||||
partition_changed_action.activate(Some(
|
partition_changed_action.activate(Some(
|
||||||
&glib::variant::Variant::from_data_with_type(row.id().to_string(), glib::VariantTy::STRING)
|
&glib::variant::Variant::from_data_with_type(
|
||||||
|
row.id().to_string(),
|
||||||
|
glib::VariantTy::STRING,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1035,10 +1057,14 @@ fn post_check_drive_mount(
|
|||||||
let used_partition_array = used_partition_array_refcell.borrow();
|
let used_partition_array = used_partition_array_refcell.borrow();
|
||||||
let subvol_partition_array = subvol_partition_array_refcell.borrow();
|
let subvol_partition_array = subvol_partition_array_refcell.borrow();
|
||||||
|
|
||||||
let action_id = String::from_utf8_lossy(varient.unwrap().data()).parse::<i32>().unwrap();
|
//dbg!(&used_partition_array);
|
||||||
|
|
||||||
|
let action_id = String::from_utf8_lossy(varient.unwrap().data())
|
||||||
|
.parse::<i32>()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
if used_partition_array.iter().any(|e| {
|
if used_partition_array.iter().any(|e| {
|
||||||
(part_name == &e.partition.part_name)
|
(part_name == &e.partition.part_name && part_name != &row.partition())
|
||||||
&& (subvol_partition_array.iter().any(|e| part_name == e))
|
&& (subvol_partition_array.iter().any(|e| part_name == e))
|
||||||
}) {
|
}) {
|
||||||
if *partition_row_struct.never.borrow() == false
|
if *partition_row_struct.never.borrow() == false
|
||||||
@ -1050,12 +1076,13 @@ fn post_check_drive_mount(
|
|||||||
(*partition_row_struct.used.borrow_mut()) = 2;
|
(*partition_row_struct.used.borrow_mut()) = 2;
|
||||||
} else if used_partition_array
|
} else if used_partition_array
|
||||||
.iter()
|
.iter()
|
||||||
.any(|e| part_name == &e.partition.part_name)
|
.any(|e| part_name == &e.partition.part_name && e.used_by != row.id() && !subvol_partition_array.iter().any(|e| part_name == e))
|
||||||
{
|
{
|
||||||
if action_id != row.id() {
|
if &row.partition() == part_name {
|
||||||
null_checkbutton.set_active(true);
|
null_checkbutton.set_active(true);
|
||||||
partition_row_struct.widget.set_sensitive(false);
|
row.set_partition("");
|
||||||
}
|
}
|
||||||
|
partition_row_struct.widget.set_sensitive(false);
|
||||||
(*partition_row_struct.used.borrow_mut()) = 1;
|
(*partition_row_struct.used.borrow_mut()) = 1;
|
||||||
} else {
|
} else {
|
||||||
if *partition_row_struct.never.borrow() == false
|
if *partition_row_struct.never.borrow() == false
|
||||||
|
@ -32,11 +32,12 @@ pub fn manual_partitioning_page(
|
|||||||
let partition_array_refcell = Rc::new(RefCell::new(get_partitions()));
|
let partition_array_refcell = Rc::new(RefCell::new(get_partitions()));
|
||||||
let used_partition_array_refcell: Rc<RefCell<Vec<FstabEntry>>> = Rc::new(RefCell::default());
|
let used_partition_array_refcell: Rc<RefCell<Vec<FstabEntry>>> = Rc::new(RefCell::default());
|
||||||
let subvol_partition_array_refcell: Rc<RefCell<Vec<String>>> = Rc::new(RefCell::default());
|
let subvol_partition_array_refcell: Rc<RefCell<Vec<String>>> = Rc::new(RefCell::default());
|
||||||
let extra_mount_id_refcell: Rc<RefCell<i32>> = Rc::new(RefCell::default());
|
let extra_mount_id_refcell: Rc<RefCell<i32>> = Rc::new(RefCell::new(3));
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
let partition_changed_action = gio::SimpleAction::new("partition-changed", Some(glib::VariantTy::STRING));
|
let partition_changed_action =
|
||||||
|
gio::SimpleAction::new("partition-changed", Some(glib::VariantTy::STRING));
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ pub fn manual_partitioning_page(
|
|||||||
&language_changed_action,
|
&language_changed_action,
|
||||||
&used_partition_array_refcell,
|
&used_partition_array_refcell,
|
||||||
&subvol_partition_array_refcell,
|
&subvol_partition_array_refcell,
|
||||||
&extra_mount_id_refcell
|
&extra_mount_id_refcell,
|
||||||
);
|
);
|
||||||
|
|
||||||
let open_disk_utility_button = gtk::Button::builder()
|
let open_disk_utility_button = gtk::Button::builder()
|
||||||
@ -167,6 +168,7 @@ pub fn manual_partitioning_page(
|
|||||||
(*partition_method_manual_crypttab_entry_array_refcell.borrow_mut()) = Vec::new();
|
(*partition_method_manual_crypttab_entry_array_refcell.borrow_mut()) = Vec::new();
|
||||||
(*used_partition_array_refcell.borrow_mut()) = Vec::new();
|
(*used_partition_array_refcell.borrow_mut()) = Vec::new();
|
||||||
(*subvol_partition_array_refcell.borrow_mut()) = Vec::new();
|
(*subvol_partition_array_refcell.borrow_mut()) = Vec::new();
|
||||||
|
(*extra_mount_id_refcell.borrow_mut()) = 3;
|
||||||
create_hardcoded_rows(
|
create_hardcoded_rows(
|
||||||
&drive_mounts_adw_listbox,
|
&drive_mounts_adw_listbox,
|
||||||
&drive_rows_size_group,
|
&drive_rows_size_group,
|
||||||
@ -175,7 +177,7 @@ pub fn manual_partitioning_page(
|
|||||||
&language_changed_action,
|
&language_changed_action,
|
||||||
&used_partition_array_refcell,
|
&used_partition_array_refcell,
|
||||||
&subvol_partition_array_refcell,
|
&subvol_partition_array_refcell,
|
||||||
&extra_mount_id_refcell
|
&extra_mount_id_refcell,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
@ -498,7 +500,7 @@ fn create_hardcoded_rows(
|
|||||||
&language_changed_action,
|
&language_changed_action,
|
||||||
&used_partition_array_refcell,
|
&used_partition_array_refcell,
|
||||||
&subvol_partition_array_refcell,
|
&subvol_partition_array_refcell,
|
||||||
&extra_mount_id_refcell
|
&extra_mount_id_refcell,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
@ -191,6 +191,7 @@ pub struct FstabEntry {
|
|||||||
pub partition: Partition,
|
pub partition: Partition,
|
||||||
pub mountpoint: String,
|
pub mountpoint: String,
|
||||||
pub mountopts: String,
|
pub mountopts: String,
|
||||||
|
pub used_by: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
|
Loading…
Reference in New Issue
Block a user