commit
35b4871c52
4 changed files with 7 additions and 10 deletions
|
|
@ -498,7 +498,6 @@ impl DhtWorker {
|
||||||
let mut futs = FuturesUnordered::new();
|
let mut futs = FuturesUnordered::new();
|
||||||
// bootstrap
|
// bootstrap
|
||||||
for addr in bootstrap_addrs.iter() {
|
for addr in bootstrap_addrs.iter() {
|
||||||
let addr = addr;
|
|
||||||
let this = &self;
|
let this = &self;
|
||||||
let in_tx = &in_tx;
|
let in_tx = &in_tx;
|
||||||
futs.push(async move {
|
futs.push(async move {
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ impl ChunkTracker {
|
||||||
pub fn new(needed_pieces: BF, have_pieces: BF, lengths: Lengths) -> Self {
|
pub fn new(needed_pieces: BF, have_pieces: BF, lengths: Lengths) -> Self {
|
||||||
// TODO: ideally this needs to be a list based on needed files, e.g.
|
// TODO: ideally this needs to be a list based on needed files, e.g.
|
||||||
// last needed piece for each file. But let's keep simple for now.
|
// last needed piece for each file. But let's keep simple for now.
|
||||||
let last_needed_piece_id = needed_pieces.iter_ones().rev().next();
|
let last_needed_piece_id = needed_pieces.iter_ones().next_back();
|
||||||
|
|
||||||
// The last pieces first. Often important information is stored in the last piece.
|
// The last pieces first. Often important information is stored in the last piece.
|
||||||
// E.g. if it's a video file, than the last piece often contains some index, or just
|
// E.g. if it's a video file, than the last piece often contains some index, or just
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ fn make_lengths<ByteBuf: AsRef<[u8]>>(
|
||||||
Lengths::new(total_length, torrent.piece_length, None)
|
Lengths::new(total_length, torrent.piece_length, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_file_length(file: &mut File, length: u64) -> anyhow::Result<()> {
|
fn ensure_file_length(file: &File, length: u64) -> anyhow::Result<()> {
|
||||||
Ok(file.set_len(length)?)
|
Ok(file.set_len(length)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,7 +237,7 @@ impl TorrentManager {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
if let Err(err) = ensure_file_length(&mut file.lock(), length) {
|
if let Err(err) = ensure_file_length(&file.lock(), length) {
|
||||||
warn!(
|
warn!(
|
||||||
"Error setting length for file {:?} to {}: {:#?}",
|
"Error setting length for file {:?} to {}: {:#?}",
|
||||||
name, length, err
|
name, length, err
|
||||||
|
|
|
||||||
|
|
@ -132,12 +132,10 @@ impl<'a, ByteBuf: 'a> UtMetadata<ByteBuf> {
|
||||||
}
|
}
|
||||||
Ok(UtMetadata::Reject(message.piece))
|
Ok(UtMetadata::Reject(message.piece))
|
||||||
}
|
}
|
||||||
other => {
|
other => Err(MessageDeserializeError::Other(anyhow::anyhow!(
|
||||||
return Err(MessageDeserializeError::Other(anyhow::anyhow!(
|
"unrecognized ut_metadata message type {}",
|
||||||
"unrecognized ut_metadata message type {}",
|
other
|
||||||
other
|
))),
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue