fix premature success send
This commit is contained in:
parent
c8fe55422b
commit
eae364e9ab
@ -9,6 +9,8 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="df2ca9e1-e07d-43f4-bc68-0a6113fc1fa2" name="Changes" comment="">
|
<list default="true" id="df2ca9e1-e07d-43f4-bc68-0a6113fc1fa2" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/bin/apt/apt_full_upgrade/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/apt/apt_full_upgrade/main.rs" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/bin/apt/apt_update/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/apt/apt_update/main.rs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/bin/gui/apt_update_page/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/gui/apt_update_page/mod.rs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/bin/gui/apt_update_page/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/gui/apt_update_page/mod.rs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/bin/gui/apt_update_page/process.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/gui/apt_update_page/process.rs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/bin/gui/apt_update_page/process.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/bin/gui/apt_update_page/process.rs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/lib/pika_unixsocket_tools/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/pika_unixsocket_tools/mod.rs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/lib/pika_unixsocket_tools/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/pika_unixsocket_tools/mod.rs" afterDir="false" />
|
||||||
@ -162,7 +164,7 @@
|
|||||||
<workItem from="1720594302708" duration="52000" />
|
<workItem from="1720594302708" duration="52000" />
|
||||||
<workItem from="1720597532937" duration="7050000" />
|
<workItem from="1720597532937" duration="7050000" />
|
||||||
<workItem from="1720648284536" duration="9271000" />
|
<workItem from="1720648284536" duration="9271000" />
|
||||||
<workItem from="1720657757166" duration="5474000" />
|
<workItem from="1720657757166" duration="6855000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use pika_unixsocket_tools::apt_install_progress_socket::AptInstallProgressSocket;
|
use pika_unixsocket_tools::apt_install_progress_socket::AptInstallProgressSocket;
|
||||||
use pika_unixsocket_tools::apt_update_progress_socket::AptUpdateProgressSocket;
|
use pika_unixsocket_tools::apt_update_progress_socket::AptUpdateProgressSocket;
|
||||||
use pika_unixsocket_tools::pika_unixsocket_tools::*;
|
use pika_unixsocket_tools::pika_unixsocket_tools::*;
|
||||||
|
use rust_apt::cache::Upgrade;
|
||||||
use rust_apt::new_cache;
|
use rust_apt::new_cache;
|
||||||
use rust_apt::progress::{AcquireProgress, InstallProgress};
|
use rust_apt::progress::{AcquireProgress, InstallProgress};
|
||||||
use std::fs::*;
|
use std::fs::*;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use rust_apt::cache::Upgrade;
|
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -59,34 +59,14 @@ fn main() {
|
|||||||
apt_upgrade_cache.resolve(true).unwrap();
|
apt_upgrade_cache.resolve(true).unwrap();
|
||||||
|
|
||||||
match apt_upgrade_cache.get_archives(&mut acquire_progress) {
|
match apt_upgrade_cache.get_archives(&mut acquire_progress) {
|
||||||
Ok(_) => {
|
Ok(_) => {}
|
||||||
Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(send_successful_to_socket(percent_socket_path));
|
|
||||||
Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(send_successful_to_socket(status_socket_path));
|
|
||||||
}
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(send_failed_to_socket(percent_socket_path));
|
|
||||||
Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(send_failed_to_socket(status_socket_path));
|
|
||||||
panic!("{}", e.to_string())
|
panic!("{}", e.to_string())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match apt_upgrade_cache.do_install(&mut install_progress) {
|
match apt_upgrade_cache.do_install(&mut install_progress) {
|
||||||
Ok(_) => {
|
Ok(_) => {}
|
||||||
Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(send_successful_to_socket(percent_socket_path));
|
|
||||||
Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(send_successful_to_socket(status_socket_path));
|
|
||||||
}
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
Runtime::new()
|
Runtime::new()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -13,14 +13,7 @@ fn main() {
|
|||||||
percent_socket_path,
|
percent_socket_path,
|
||||||
status_socket_path,
|
status_socket_path,
|
||||||
))) {
|
))) {
|
||||||
Ok(_) => {
|
Ok(_) => {}
|
||||||
Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(send_successful_to_socket(percent_socket_path));
|
|
||||||
Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(send_successful_to_socket(status_socket_path));
|
|
||||||
}
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
Runtime::new()
|
Runtime::new()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -61,7 +61,7 @@ pub fn apt_update_page(
|
|||||||
Runtime::new().unwrap().block_on(start_socket_server(
|
Runtime::new().unwrap().block_on(start_socket_server(
|
||||||
update_status_sender,
|
update_status_sender,
|
||||||
"/tmp/pika_apt_update_status.sock",
|
"/tmp/pika_apt_update_status.sock",
|
||||||
"/tmp/pika-apt-update.log"
|
"/tmp/pika-apt-update.log",
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -71,7 +71,9 @@ pub fn apt_update_page(
|
|||||||
.status()
|
.status()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
match apt_update_command.code().unwrap() {
|
match apt_update_command.code().unwrap() {
|
||||||
0 => {}
|
0 => update_status_sender_clone0
|
||||||
|
.send_blocking("FN_OVERRIDE_SUCCESSFUL".to_owned())
|
||||||
|
.unwrap(),
|
||||||
53 => {}
|
53 => {}
|
||||||
_ => {
|
_ => {
|
||||||
update_status_sender_clone0
|
update_status_sender_clone0
|
||||||
@ -218,6 +220,15 @@ pub fn apt_update_page(
|
|||||||
// The main loop executes the asynchronous block
|
// The main loop executes the asynchronous block
|
||||||
update_percent_server_context.spawn_local(clone!(@weak apt_update_dialog_progress_bar, @weak apt_update_dialog, @strong get_upgradable_sender => async move {
|
update_percent_server_context.spawn_local(clone!(@weak apt_update_dialog_progress_bar, @weak apt_update_dialog, @strong get_upgradable_sender => async move {
|
||||||
while let Ok(state) = update_percent_receiver.recv().await {
|
while let Ok(state) = update_percent_receiver.recv().await {
|
||||||
|
apt_update_dialog_progress_bar.set_fraction(state.parse::<f64>().unwrap()/100.0)
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
let update_status_server_context = MainContext::default();
|
||||||
|
// The main loop executes the asynchronous block
|
||||||
|
update_status_server_context.spawn_local(
|
||||||
|
clone!(@weak apt_update_dialog, @weak apt_update_dialog_child_box => async move {
|
||||||
|
while let Ok(state) = update_status_receiver.recv().await {
|
||||||
match state.as_ref() {
|
match state.as_ref() {
|
||||||
"FN_OVERRIDE_SUCCESSFUL" => {
|
"FN_OVERRIDE_SUCCESSFUL" => {
|
||||||
let get_upgradable_sender = get_upgradable_sender.clone();
|
let get_upgradable_sender = get_upgradable_sender.clone();
|
||||||
@ -258,20 +269,6 @@ pub fn apt_update_page(
|
|||||||
});
|
});
|
||||||
apt_update_dialog.close();
|
apt_update_dialog.close();
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
apt_update_dialog_progress_bar.set_fraction(state.parse::<f64>().unwrap()/100.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
let update_status_server_context = MainContext::default();
|
|
||||||
// The main loop executes the asynchronous block
|
|
||||||
update_status_server_context.spawn_local(
|
|
||||||
clone!(@weak apt_update_dialog, @weak apt_update_dialog_child_box => async move {
|
|
||||||
while let Ok(state) = update_status_receiver.recv().await {
|
|
||||||
match state.as_ref() {
|
|
||||||
"FN_OVERRIDE_SUCCESSFUL" => {}
|
|
||||||
"FN_OVERRIDE_FAILED" => {
|
"FN_OVERRIDE_FAILED" => {
|
||||||
apt_update_dialog_child_box.set_visible(false);
|
apt_update_dialog_child_box.set_visible(false);
|
||||||
apt_update_dialog.set_extra_child(Some(>k::Image::builder().pixel_size(128).icon_name("dialog-error-symbolic").halign(Align::Center).build()));
|
apt_update_dialog.set_extra_child(Some(>k::Image::builder().pixel_size(128).icon_name("dialog-error-symbolic").halign(Align::Center).build()));
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
use adw::gio::SimpleAction;
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use gtk::glib::*;
|
use gtk::glib::*;
|
||||||
use gtk::*;
|
use gtk::*;
|
||||||
use pika_unixsocket_tools::pika_unixsocket_tools::{start_socket_server, start_socket_server_no_log};
|
use pika_unixsocket_tools::pika_unixsocket_tools::{
|
||||||
|
start_socket_server, start_socket_server_no_log,
|
||||||
|
};
|
||||||
use pretty_bytes::converter::convert;
|
use pretty_bytes::converter::convert;
|
||||||
use rust_apt::cache::Upgrade;
|
use rust_apt::cache::Upgrade;
|
||||||
use rust_apt::new_cache;
|
use rust_apt::new_cache;
|
||||||
@ -10,7 +13,6 @@ use serde_json::Value;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::{fs::*, thread};
|
use std::{fs::*, thread};
|
||||||
use adw::gio::SimpleAction;
|
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
struct AptChangesInfo {
|
struct AptChangesInfo {
|
||||||
@ -53,7 +55,11 @@ impl AptChangesInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apt_process_update(excluded_updates_vec: &Vec<String>, window: adw::ApplicationWindow, retry_signal_action: &SimpleAction,) {
|
pub fn apt_process_update(
|
||||||
|
excluded_updates_vec: &Vec<String>,
|
||||||
|
window: adw::ApplicationWindow,
|
||||||
|
retry_signal_action: &SimpleAction,
|
||||||
|
) {
|
||||||
let excluded_updates_alert_dialog = adw::MessageDialog::builder()
|
let excluded_updates_alert_dialog = adw::MessageDialog::builder()
|
||||||
.transient_for(&window)
|
.transient_for(&window)
|
||||||
.heading(t!("excluded_updates_alert_dialog_heading"))
|
.heading(t!("excluded_updates_alert_dialog_heading"))
|
||||||
@ -97,7 +103,11 @@ pub fn apt_process_update(excluded_updates_vec: &Vec<String>, window: adw::Appli
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apt_confirm_window(excluded_updates_vec: &Vec<String>, window: adw::ApplicationWindow, retry_signal_action: &SimpleAction,) {
|
fn apt_confirm_window(
|
||||||
|
excluded_updates_vec: &Vec<String>,
|
||||||
|
window: adw::ApplicationWindow,
|
||||||
|
retry_signal_action: &SimpleAction,
|
||||||
|
) {
|
||||||
// Emulate Apt Full Upgrade to get transaction info
|
// Emulate Apt Full Upgrade to get transaction info
|
||||||
let mut apt_changes_struct = AptChangesInfo {
|
let mut apt_changes_struct = AptChangesInfo {
|
||||||
package_count_upgrade: 0,
|
package_count_upgrade: 0,
|
||||||
@ -284,14 +294,20 @@ fn apt_confirm_window(excluded_updates_vec: &Vec<String>, window: adw::Applicati
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apt_full_upgrade_from_socket(window: adw::ApplicationWindow, retry_signal_action: &SimpleAction) {
|
fn apt_full_upgrade_from_socket(
|
||||||
|
window: adw::ApplicationWindow,
|
||||||
|
retry_signal_action: &SimpleAction,
|
||||||
|
) {
|
||||||
let (upgrade_percent_sender, upgrade_percent_receiver) = async_channel::unbounded::<String>();
|
let (upgrade_percent_sender, upgrade_percent_receiver) = async_channel::unbounded::<String>();
|
||||||
let upgrade_percent_sender = upgrade_percent_sender.clone();
|
let upgrade_percent_sender = upgrade_percent_sender.clone();
|
||||||
let (upgrade_status_sender, upgrade_status_receiver) = async_channel::unbounded::<String>();
|
let (upgrade_status_sender, upgrade_status_receiver) = async_channel::unbounded::<String>();
|
||||||
let upgrade_status_sender = upgrade_status_sender.clone();
|
let upgrade_status_sender = upgrade_status_sender.clone();
|
||||||
let upgrade_status_sender_clone0 = upgrade_status_sender.clone();
|
let upgrade_status_sender_clone0 = upgrade_status_sender.clone();
|
||||||
|
|
||||||
let log_file_path = format!("/tmp/pika-apt-upgrade_{}.log", chrono::offset::Local::now().format("%Y-%m-%d_%H:%M"));
|
let log_file_path = format!(
|
||||||
|
"/tmp/pika-apt-upgrade_{}.log",
|
||||||
|
chrono::offset::Local::now().format("%Y-%m-%d_%H:%M")
|
||||||
|
);
|
||||||
let log_file_path_clone0 = log_file_path.clone();
|
let log_file_path_clone0 = log_file_path.clone();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
@ -305,13 +321,15 @@ fn apt_full_upgrade_from_socket(window: adw::ApplicationWindow, retry_signal_act
|
|||||||
Runtime::new().unwrap().block_on(start_socket_server(
|
Runtime::new().unwrap().block_on(start_socket_server(
|
||||||
upgrade_status_sender,
|
upgrade_status_sender,
|
||||||
"/tmp/pika_apt_upgrade_status.sock",
|
"/tmp/pika_apt_upgrade_status.sock",
|
||||||
&log_file_path
|
&log_file_path,
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let apt_upgrade_command = Command::new("pkexec")
|
let apt_upgrade_command = Command::new("pkexec")
|
||||||
.args(["/home/ward/RustroverProjects/pikman-update-manager/target/debug/apt_full_upgrade"])
|
.args([
|
||||||
|
"/home/ward/RustroverProjects/pikman-update-manager/target/debug/apt_full_upgrade",
|
||||||
|
])
|
||||||
.status()
|
.status()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
match apt_upgrade_command.code().unwrap() {
|
match apt_upgrade_command.code().unwrap() {
|
||||||
@ -430,8 +448,10 @@ fn apt_full_upgrade_from_socket(window: adw::ApplicationWindow, retry_signal_act
|
|||||||
|
|
||||||
let retry_signal_action0 = retry_signal_action.clone();
|
let retry_signal_action0 = retry_signal_action.clone();
|
||||||
|
|
||||||
apt_upgrade_log_button.connect_clicked( move |_| {
|
apt_upgrade_log_button.connect_clicked(move |_| {
|
||||||
let _ = std::process::Command::new("xdg-open").arg(log_file_path_clone0.to_owned()).spawn();
|
let _ = std::process::Command::new("xdg-open")
|
||||||
|
.arg(log_file_path_clone0.to_owned())
|
||||||
|
.spawn();
|
||||||
});
|
});
|
||||||
|
|
||||||
apt_upgrade_dialog.choose(None::<&gio::Cancellable>, move |choice| {
|
apt_upgrade_dialog.choose(None::<&gio::Cancellable>, move |choice| {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
|
use chrono;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use std::fs::OpenOptions;
|
||||||
|
use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio::net::{UnixListener, UnixStream};
|
use tokio::net::{UnixListener, UnixStream};
|
||||||
use tokio::task;
|
use tokio::task;
|
||||||
use chrono;
|
|
||||||
use std::fs::OpenOptions;
|
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
pub async fn send_successful_to_socket(socket_path: &str) {
|
pub async fn send_successful_to_socket(socket_path: &str) {
|
||||||
// Connect to the Unix socket
|
// Connect to the Unix socket
|
||||||
@ -38,7 +38,11 @@ pub async fn send_failed_to_socket(socket_path: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Function to handle a single client connection
|
// Function to handle a single client connection
|
||||||
pub async fn handle_client(mut stream: UnixStream, buffer_sender: async_channel::Sender<String>, log_file_path: String) {
|
pub async fn handle_client(
|
||||||
|
mut stream: UnixStream,
|
||||||
|
buffer_sender: async_channel::Sender<String>,
|
||||||
|
log_file_path: String,
|
||||||
|
) {
|
||||||
// Buffer to store incoming data
|
// Buffer to store incoming data
|
||||||
let mut buffer = [0; 1024];
|
let mut buffer = [0; 1024];
|
||||||
|
|
||||||
@ -66,7 +70,12 @@ pub async fn handle_client(mut stream: UnixStream, buffer_sender: async_channel:
|
|||||||
.open(&log_file_path)
|
.open(&log_file_path)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
if let Err(e) = writeln!(log_file, "[{}] {}", chrono::offset::Local::now().format("%Y/%m/%d_%H:%M"), message) {
|
if let Err(e) = writeln!(
|
||||||
|
log_file,
|
||||||
|
"[{}] {}",
|
||||||
|
chrono::offset::Local::now().format("%Y/%m/%d_%H:%M"),
|
||||||
|
message
|
||||||
|
) {
|
||||||
eprintln!("Couldn't write to file: {}", e);
|
eprintln!("Couldn't write to file: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +86,11 @@ pub async fn handle_client(mut stream: UnixStream, buffer_sender: async_channel:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn start_socket_server(buffer_sender: async_channel::Sender<String>, socket_path: &str, log_file_path: &str) {
|
pub async fn start_socket_server(
|
||||||
|
buffer_sender: async_channel::Sender<String>,
|
||||||
|
socket_path: &str,
|
||||||
|
log_file_path: &str,
|
||||||
|
) {
|
||||||
// Remove the socket file if it already exists
|
// Remove the socket file if it already exists
|
||||||
if Path::new(socket_path).exists() {
|
if Path::new(socket_path).exists() {
|
||||||
fs::remove_file(socket_path).expect("Could not remove existing socket file");
|
fs::remove_file(socket_path).expect("Could not remove existing socket file");
|
||||||
@ -94,7 +107,11 @@ pub async fn start_socket_server(buffer_sender: async_channel::Sender<String>, s
|
|||||||
match listener.accept().await {
|
match listener.accept().await {
|
||||||
Ok((stream, _)) => {
|
Ok((stream, _)) => {
|
||||||
// Handle the connection in a separate task
|
// Handle the connection in a separate task
|
||||||
task::spawn(handle_client(stream, buffer_sender.clone(), log_file_path.to_owned()));
|
task::spawn(handle_client(
|
||||||
|
stream,
|
||||||
|
buffer_sender.clone(),
|
||||||
|
log_file_path.to_owned(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Print error message if a connection fails
|
// Print error message if a connection fails
|
||||||
@ -104,7 +121,10 @@ pub async fn start_socket_server(buffer_sender: async_channel::Sender<String>, s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_client_no_log(mut stream: UnixStream, buffer_sender: async_channel::Sender<String>) {
|
pub async fn handle_client_no_log(
|
||||||
|
mut stream: UnixStream,
|
||||||
|
buffer_sender: async_channel::Sender<String>,
|
||||||
|
) {
|
||||||
// Buffer to store incoming data
|
// Buffer to store incoming data
|
||||||
let mut buffer = [0; 1024];
|
let mut buffer = [0; 1024];
|
||||||
|
|
||||||
@ -126,7 +146,10 @@ pub async fn handle_client_no_log(mut stream: UnixStream, buffer_sender: async_c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn start_socket_server_no_log(buffer_sender: async_channel::Sender<String>, socket_path: &str) {
|
pub async fn start_socket_server_no_log(
|
||||||
|
buffer_sender: async_channel::Sender<String>,
|
||||||
|
socket_path: &str,
|
||||||
|
) {
|
||||||
// Remove the socket file if it already exists
|
// Remove the socket file if it already exists
|
||||||
if Path::new(socket_path).exists() {
|
if Path::new(socket_path).exists() {
|
||||||
fs::remove_file(socket_path).expect("Could not remove existing socket file");
|
fs::remove_file(socket_path).expect("Could not remove existing socket file");
|
||||||
@ -143,7 +166,10 @@ pub async fn start_socket_server_no_log(buffer_sender: async_channel::Sender<Str
|
|||||||
match listener.accept().await {
|
match listener.accept().await {
|
||||||
Ok((stream, _)) => {
|
Ok((stream, _)) => {
|
||||||
// Handle the connection in a separate task
|
// Handle the connection in a separate task
|
||||||
task::spawn(crate::pika_unixsocket_tools::handle_client_no_log(stream, buffer_sender.clone()));
|
task::spawn(crate::pika_unixsocket_tools::handle_client_no_log(
|
||||||
|
stream,
|
||||||
|
buffer_sender.clone(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Print error message if a connection fails
|
// Print error message if a connection fails
|
||||||
|
Loading…
Reference in New Issue
Block a user