chore: update to Rust 2024 edition
This commit is contained in:
@@ -156,13 +156,12 @@ impl PeerActor {
|
||||
let transfer_response =
|
||||
MessageFactory::build_transfer_response_message(transfer);
|
||||
|
||||
if let Some(ref handle) = self.self_handle {
|
||||
if let Err(e) =
|
||||
if let Some(ref handle) = self.self_handle
|
||||
&& let Err(e) =
|
||||
handle.send(PeerMessage::SendMessage(transfer_response))
|
||||
{
|
||||
error!("[peer:{}] Failed to send TransferResponse message: {}", username, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
PeerMessage::TransferResponse {
|
||||
token,
|
||||
|
||||
@@ -285,11 +285,10 @@ impl Client {
|
||||
#[allow(dead_code)]
|
||||
pub fn remove_peer(&self, username: &str) {
|
||||
let context = self.context.read().unwrap();
|
||||
if let Some(ref registry) = context.peer_registry {
|
||||
if let Some(handle) = registry.remove_peer(username) {
|
||||
if let Some(ref registry) = context.peer_registry
|
||||
&& let Some(handle) = registry.remove_peer(username) {
|
||||
let _ = handle.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn search(
|
||||
@@ -334,12 +333,11 @@ impl Client {
|
||||
sleep(Duration::from_millis(100));
|
||||
|
||||
// Check if cancelled
|
||||
if let Some(ref flag) = cancel_flag {
|
||||
if flag.load(Ordering::Relaxed) {
|
||||
if let Some(ref flag) = cancel_flag
|
||||
&& flag.load(Ordering::Relaxed) {
|
||||
info!("Search cancelled by user");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if timeout reached
|
||||
if start.elapsed() >= timeout {
|
||||
@@ -504,13 +502,12 @@ impl Client {
|
||||
}
|
||||
ClientOperation::PeerDisconnected(username, error) => {
|
||||
let context = client_context.read().unwrap();
|
||||
if let Some(ref registry) = context.peer_registry {
|
||||
if let Some(handle) =
|
||||
if let Some(ref registry) = context.peer_registry
|
||||
&& let Some(handle) =
|
||||
registry.remove_peer(&username)
|
||||
{
|
||||
let _ = handle.stop();
|
||||
}
|
||||
}
|
||||
if let Some(error) = error {
|
||||
warn!(
|
||||
"[client] Peer {} disconnected with error: {:?}",
|
||||
|
||||
@@ -306,8 +306,8 @@ impl DownloadPeer {
|
||||
processor.process_data_chunk(data);
|
||||
chunk_counter += 1;
|
||||
|
||||
if let Some(ref dl) = download {
|
||||
if chunk_counter % PROGRESS_UPDATE_CHUNKS == 0 {
|
||||
if let Some(ref dl) = download
|
||||
&& chunk_counter % PROGRESS_UPDATE_CHUNKS == 0 {
|
||||
let elapsed =
|
||||
last_update_time.elapsed().as_secs_f64();
|
||||
let bytes_since_last_update =
|
||||
@@ -331,7 +331,6 @@ impl DownloadPeer {
|
||||
|
||||
last_update_time = Instant::now();
|
||||
}
|
||||
}
|
||||
|
||||
let expected_size = download
|
||||
.as_ref()
|
||||
|
||||
@@ -167,12 +167,11 @@ pub fn log(level: LogLevel, message: &str) {
|
||||
buffer.push(formatted_message.clone());
|
||||
}
|
||||
// But ALSO write to file if configured (file logging bypasses buffering)
|
||||
if let Ok(mut log_file) = LOG_FILE.lock() {
|
||||
if let Some(file) = log_file.as_mut() {
|
||||
if let Ok(mut log_file) = LOG_FILE.lock()
|
||||
&& let Some(file) = log_file.as_mut() {
|
||||
let _ = writeln!(file, "{}", formatted_message_plain);
|
||||
let _ = file.flush();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Write to file if configured, otherwise to stderr
|
||||
if let Ok(mut log_file) = LOG_FILE.lock() {
|
||||
|
||||
Reference in New Issue
Block a user