Fix clippy lints related to recent bug

This commit is contained in:
Igor Katson 2024-04-24 14:19:04 +01:00
parent 5dee78227b
commit 3d46d7cb97
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
13 changed files with 89 additions and 78 deletions

View file

@ -145,8 +145,8 @@ impl<'a> FileOps<'a> {
progress.fetch_add(piece_info.len as u64, Ordering::Relaxed);
while piece_remaining > 0 {
let mut to_read_in_file =
std::cmp::min(current_file.remaining(), piece_remaining as u64) as usize;
let mut to_read_in_file: usize =
std::cmp::min(current_file.remaining(), piece_remaining as u64).try_into()?;
// Keep changing the current file to next until we find a file that has greater than 0 length.
while to_read_in_file == 0 {
@ -157,7 +157,8 @@ impl<'a> FileOps<'a> {
piece_selected |= current_file.full_file_required;
to_read_in_file =
std::cmp::min(current_file.remaining(), piece_remaining as u64) as usize;
std::cmp::min(current_file.remaining(), piece_remaining as u64)
.try_into()?;
}
piece_files.push(current_file.index);
@ -265,7 +266,7 @@ impl<'a> FileOps<'a> {
let file_remaining_len = file_len - absolute_offset;
let to_read_in_file =
std::cmp::min(file_remaining_len, piece_remaining_bytes as u64) as usize;
std::cmp::min(file_remaining_len, piece_remaining_bytes as u64).try_into()?;
let mut file_g = self.files[file_idx].file.lock();
trace!(
"piece={}, handle={}, file_idx={}, seeking to {}. Last received chunk: {:?}",
@ -332,7 +333,7 @@ impl<'a> FileOps<'a> {
continue;
}
let file_remaining_len = file_len - absolute_offset;
let to_read_in_file = std::cmp::min(file_remaining_len, buf.len() as u64) as usize;
let to_read_in_file = std::cmp::min(file_remaining_len, buf.len() as u64).try_into()?;
let mut file_g = self.files[file_idx].file.lock();
trace!(
@ -385,7 +386,7 @@ impl<'a> FileOps<'a> {
}
let remaining_len = file_len - absolute_offset;
let to_write = std::cmp::min(buf.len() as u64, remaining_len) as usize;
let to_write = std::cmp::min(buf.len() as u64, remaining_len).try_into()?;
let mut file_g = self.files[file_idx].file.lock();
trace!(