fix refresh lock
All checks were successful
PikaOS Package Build & Release (amd64-v3) / build (push) Successful in 2m15s

This commit is contained in:
Ward from fusion-voyager-3 2024-10-06 22:59:21 +03:00
parent e33e800131
commit f33d2254f0
8 changed files with 103 additions and 27 deletions

View File

@ -1 +1 @@
12 13

44
Cargo.lock generated
View File

@ -526,7 +526,7 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
dependencies = [ dependencies = [
"memoffset", "memoffset 0.9.1",
"rustc_version 0.4.0", "rustc_version 0.4.0",
] ]
@ -1441,6 +1441,15 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "memoffset"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "memoffset" name = "memoffset"
version = "0.9.1" version = "0.9.1"
@ -1546,6 +1555,19 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "nix"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c"
dependencies = [
"bitflags 1.3.2",
"cc",
"cfg-if 1.0.0",
"libc",
"memoffset 0.6.5",
]
[[package]] [[package]]
name = "normpath" name = "normpath"
version = "1.2.0" version = "1.2.0"
@ -1759,6 +1781,7 @@ dependencies = [
"rust-i18n", "rust-i18n",
"serde", "serde",
"serde_json", "serde_json",
"single-instance",
"strfmt", "strfmt",
"tokio", "tokio",
"tokio-uds", "tokio-uds",
@ -2223,6 +2246,19 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "single-instance"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4637485391f8545c9d3dbf60f9d9aab27a90c789a700999677583bcb17c8795d"
dependencies = [
"libc",
"nix",
"thiserror",
"widestring",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.9" version = "0.4.9"
@ -2863,6 +2899,12 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "widestring"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.2.8" version = "0.2.8"

View File

@ -45,4 +45,5 @@ reqwest = { version = "0.11", features = ["blocking"] }
strfmt = "0.2.4" strfmt = "0.2.4"
configparser = "3.1.0" configparser = "3.1.0"
ksni = "0.2.2" ksni = "0.2.2"
single-instance = "0.3.3"

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
pikman-update-manager (1.0.1-100pika3) pikauwu; urgency=medium pikman-update-manager (1.0.1-100pika4) pikauwu; urgency=medium
* initial release * initial release

View File

@ -13,6 +13,10 @@ i18n!("locales", fallback = "en_US");
fn main() { fn main() {
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
rust_i18n::set_locale(&args[1]); rust_i18n::set_locale(&args[1]);
let instance = single_instance::SingleInstance::new(
"com.github.pikaos-linux.pikmanupdatemanager.update.manager",
)
.unwrap();
let hit_strfmt_trans_str = t!("apt_update_str_hit").to_string(); let hit_strfmt_trans_str = t!("apt_update_str_hit").to_string();
let fetch_strfmt_trans_str = t!("apt_update_str_fetch").to_string(); let fetch_strfmt_trans_str = t!("apt_update_str_fetch").to_string();
@ -41,4 +45,6 @@ fn main() {
panic!("{}", e.to_string()) panic!("{}", e.to_string())
} }
}; };
assert!(!instance.is_single());
} }

View File

@ -65,10 +65,24 @@ pub fn apt_update_page(
}); });
thread::spawn(move || { thread::spawn(move || {
let instance = single_instance::SingleInstance::new(
"com.github.pikaos-linux.pikmanupdatemanager.update.manager",
)
.unwrap();
if instance.is_single() {
let current_locale = match std::env::var_os("LANG") {
Some(v) => v
.into_string()
.unwrap()
.chars()
.take_while(|&ch| ch != '.')
.collect::<String>(),
None => panic!("$LANG is not set"),
};
let apt_update_command = Command::new("pkexec") let apt_update_command = Command::new("pkexec")
.args([ .args([
"/usr/lib/pika/pikman-update-manager/scripts/apt_update", "/usr/lib/pika/pikman-update-manager/scripts/apt_update",
"fr_FR", &current_locale,
]) ])
.status() .status()
.unwrap(); .unwrap();
@ -86,6 +100,7 @@ pub fn apt_update_page(
.unwrap() .unwrap()
} }
} }
};
}); });
let main_box = Box::builder() let main_box = Box::builder()

View File

@ -411,8 +411,20 @@ fn apt_full_upgrade_from_socket(
}); });
thread::spawn(move || { thread::spawn(move || {
let current_locale = match std::env::var_os("LANG") {
Some(v) => v
.into_string()
.unwrap()
.chars()
.take_while(|&ch| ch != '.')
.collect::<String>(),
None => panic!("$LANG is not set"),
};
let apt_upgrade_command = Command::new("pkexec") let apt_upgrade_command = Command::new("pkexec")
.args(["/usr/lib/pika/pikman-update-manager/scripts/apt_full_upgrade"]) .args([
"/usr/lib/pika/pikman-update-manager/scripts/apt_full_upgrade",
&current_locale,
])
.status() .status()
.unwrap(); .unwrap();
match apt_upgrade_command.code().unwrap() { match apt_upgrade_command.code().unwrap() {

View File

@ -134,8 +134,8 @@ pub fn build_ui(app: &Application) {
update_sys_tray.connect_activate(clone!( update_sys_tray.connect_activate(clone!(
#[strong] #[strong]
tray_handle, tray_handle,
#[strong] /*#[strong]
refresh_button, refresh_button,*/
move |_, param| { move |_, param| {
let array: &[i32] = param.unwrap().fixed_array().unwrap(); let array: &[i32] = param.unwrap().fixed_array().unwrap();
let vec = array.to_vec(); let vec = array.to_vec();
@ -175,7 +175,7 @@ pub fn build_ui(app: &Application) {
.unwrap(), .unwrap(),
); );
}); });
if apt_update_count == -1 || flatpak_update_count == -1 { /*if apt_update_count == -1 || flatpak_update_count == -1 {
refresh_button.set_sensitive(false); refresh_button.set_sensitive(false);
refresh_button.set_tooltip_text(Some( refresh_button.set_tooltip_text(Some(
&t!("pikman_indicator_flatpak_item_label_calculating").to_string(), &t!("pikman_indicator_flatpak_item_label_calculating").to_string(),
@ -184,7 +184,7 @@ pub fn build_ui(app: &Application) {
refresh_button.set_sensitive(true); refresh_button.set_sensitive(true);
refresh_button refresh_button
.set_tooltip_text(Some(&t!("refresh_button_tooltip_text").to_string())); .set_tooltip_text(Some(&t!("refresh_button_tooltip_text").to_string()));
} }*/
} }
)); ));
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[-1, -1]))); update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[-1, -1])));