fix: linting
This commit is contained in:
@@ -384,7 +384,7 @@ impl Client {
|
||||
username: String,
|
||||
size: u64,
|
||||
download_directory: String,
|
||||
) -> Result<Receiver<DownloadStatus>> {
|
||||
) -> Result<(Download, Receiver<DownloadStatus>)> {
|
||||
info!("[client] Downloading {} from {}", filename, username);
|
||||
|
||||
let hash = md5::md5(&filename);
|
||||
@@ -421,10 +421,13 @@ impl Client {
|
||||
|
||||
if !download_initiated {
|
||||
let _ = download.sender.send(DownloadStatus::Failed);
|
||||
self.context.write().unwrap().update_download_with_status(token, DownloadStatus::Failed);
|
||||
self.context
|
||||
.write()
|
||||
.unwrap()
|
||||
.update_download_with_status(token, DownloadStatus::Failed);
|
||||
}
|
||||
|
||||
Ok(download_receiver)
|
||||
Ok((download, download_receiver))
|
||||
}
|
||||
|
||||
fn process_failed_uploads(
|
||||
@@ -811,7 +814,13 @@ impl Client {
|
||||
download.size
|
||||
);
|
||||
let _ = download.sender.send(DownloadStatus::Completed);
|
||||
client_context.write().unwrap().update_download_with_status(download.token, DownloadStatus::Completed);
|
||||
client_context
|
||||
.write()
|
||||
.unwrap()
|
||||
.update_download_with_status(
|
||||
download.token,
|
||||
DownloadStatus::Completed,
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
trace!("[client] failed to download: {}", e);
|
||||
|
||||
@@ -22,6 +22,4 @@ pub mod prelude {
|
||||
pub use actor::server_actor::PeerAddress;
|
||||
pub use client::{Client, ClientSettings};
|
||||
pub use error::{Result, SoulseekRs};
|
||||
pub use types::{
|
||||
DownloadStatus, File, Search, SearchResult, Transfer,
|
||||
};
|
||||
pub use types::{DownloadStatus, File, Search, SearchResult, Transfer};
|
||||
|
||||
@@ -242,7 +242,8 @@ impl DownloadPeer {
|
||||
let client_guard = client_context
|
||||
.read()
|
||||
.map_err(|_| DownloadError::LockPoisoned)?;
|
||||
let download_info = client_guard.get_download_by_token(token_u32).cloned();
|
||||
let download_info =
|
||||
client_guard.get_download_by_token(token_u32).cloned();
|
||||
drop(client_guard);
|
||||
|
||||
download_info.ok_or(DownloadError::TokenNotFound(token_u32))
|
||||
@@ -323,7 +324,10 @@ impl DownloadPeer {
|
||||
speed_bytes_per_sec: speed,
|
||||
};
|
||||
let _ = dl.sender.send(status.clone());
|
||||
client_context.write().unwrap().update_download_with_status(dl.token, status);
|
||||
client_context
|
||||
.write()
|
||||
.unwrap()
|
||||
.update_download_with_status(dl.token, status);
|
||||
|
||||
last_update_time = Instant::now();
|
||||
}
|
||||
@@ -421,7 +425,10 @@ impl DownloadPeer {
|
||||
|
||||
if let Some(ref dl) = download {
|
||||
let _ = dl.sender.send(DownloadStatus::Queued);
|
||||
client_context.write().unwrap().update_download_with_status(dl.token, DownloadStatus::Queued);
|
||||
client_context
|
||||
.write()
|
||||
.unwrap()
|
||||
.update_download_with_status(dl.token, DownloadStatus::Queued);
|
||||
}
|
||||
|
||||
let mut stream = match stream {
|
||||
|
||||
@@ -157,7 +157,14 @@ fn handle_file_connection(
|
||||
) {
|
||||
Ok((download, filename)) => {
|
||||
let _ = download.sender.send(DownloadStatus::Completed);
|
||||
context.client_context.write().unwrap().update_download_with_status(download.token, DownloadStatus::Completed);
|
||||
context
|
||||
.client_context
|
||||
.write()
|
||||
.unwrap()
|
||||
.update_download_with_status(
|
||||
download.token,
|
||||
DownloadStatus::Completed,
|
||||
);
|
||||
info!(
|
||||
"Successfully downloaded {} bytes to {}",
|
||||
download.size, filename
|
||||
|
||||
@@ -102,13 +102,17 @@ impl Download {
|
||||
pub fn is_finished(&self) -> bool {
|
||||
matches!(
|
||||
self.status,
|
||||
DownloadStatus::Completed | DownloadStatus::Failed | DownloadStatus::TimedOut
|
||||
DownloadStatus::Completed
|
||||
| DownloadStatus::Failed
|
||||
| DownloadStatus::TimedOut
|
||||
)
|
||||
}
|
||||
|
||||
pub fn bytes_downloaded(&self) -> u64 {
|
||||
match &self.status {
|
||||
DownloadStatus::InProgress { bytes_downloaded, .. } => *bytes_downloaded,
|
||||
DownloadStatus::InProgress {
|
||||
bytes_downloaded, ..
|
||||
} => *bytes_downloaded,
|
||||
DownloadStatus::Completed => self.size,
|
||||
_ => 0,
|
||||
}
|
||||
@@ -116,7 +120,10 @@ impl Download {
|
||||
|
||||
pub fn speed_bytes_per_sec(&self) -> f64 {
|
||||
match &self.status {
|
||||
DownloadStatus::InProgress { speed_bytes_per_sec, .. } => *speed_bytes_per_sec,
|
||||
DownloadStatus::InProgress {
|
||||
speed_bytes_per_sec,
|
||||
..
|
||||
} => *speed_bytes_per_sec,
|
||||
_ => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,10 @@ pub fn init() {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to open log file '{}': {}", log_file_path, e);
|
||||
eprintln!(
|
||||
"Failed to open log file '{}': {}",
|
||||
log_file_path, e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user