fixing bugs

This commit is contained in:
Igor Katson 2024-08-14 10:53:25 +01:00
parent c196c11860
commit 53d61d0428
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
4 changed files with 87 additions and 55 deletions

View file

@ -857,6 +857,19 @@ impl<'a> PeerConnectionHandler for &'a PeerHandler {
.unwrap_or(true);
!have
}
fn update_my_extended_handshake(
&self,
handshake: &mut ExtendedHandshake<ByteBuf>,
) -> anyhow::Result<()> {
let info_bytes = &self.state.meta().info_bytes;
if !info_bytes.is_empty() {
if let Ok(len) = info_bytes.len().try_into() {
handshake.metadata_size = Some(len);
}
}
Ok(())
}
}
impl PeerHandler {

View file

@ -101,6 +101,7 @@ pub(crate) struct ManagedTorrentOptions {
pub struct ManagedTorrentInfo {
pub info: TorrentMetaV1Info<ByteBufOwned>,
pub torrent_bytes: Bytes,
pub info_bytes: Bytes,
pub info_hash: Id20,
pub(crate) spawner: BlockingSpawner,
pub trackers: HashSet<String>,
@ -504,6 +505,7 @@ pub(crate) struct ManagedTorrentBuilder {
output_folder: PathBuf,
info_hash: Id20,
torrent_bytes: Bytes,
info_bytes: Bytes,
force_tracker_interval: Option<Duration>,
peer_connect_timeout: Option<Duration>,
peer_read_write_timeout: Option<Duration>,
@ -522,6 +524,7 @@ impl ManagedTorrentBuilder {
info: TorrentMetaV1Info<ByteBufOwned>,
info_hash: Id20,
torrent_bytes: Bytes,
info_bytes: Bytes,
output_folder: PathBuf,
storage_factory: BoxStorageFactory,
) -> Self {
@ -529,6 +532,7 @@ impl ManagedTorrentBuilder {
info,
info_hash,
torrent_bytes,
info_bytes,
spawner: None,
force_tracker_interval: None,
peer_connect_timeout: None,
@ -614,6 +618,7 @@ impl ManagedTorrentBuilder {
file_infos,
info: self.info,
torrent_bytes: self.torrent_bytes,
info_bytes: self.info_bytes,
info_hash: self.info_hash,
trackers: self.trackers.into_iter().collect(),
spawner: self.spawner.unwrap_or_default(),