diff --git a/crates/librqbit/src/http_api.rs b/crates/librqbit/src/http_api.rs index e86e31d..41cb617 100644 --- a/crates/librqbit/src/http_api.rs +++ b/crates/librqbit/src/http_api.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Context}; +use anyhow::{Context}; use axum::body::Bytes; use axum::extract::{Path, Query, State}; use axum::response::IntoResponse; @@ -472,7 +472,7 @@ impl ApiInternal { }) } - fn api_dump_haves(&self, idx: usize) -> Result { + fn api_dump_haves(&self, _idx: usize) -> Result { Err(anyhow::anyhow!("not implemented").into()) // let mgr = self.mgr_handle(idx)?; // Ok(format!( diff --git a/crates/librqbit/src/session.rs b/crates/librqbit/src/session.rs index ddc213d..d4bbd28 100644 --- a/crates/librqbit/src/session.rs +++ b/crates/librqbit/src/session.rs @@ -17,7 +17,7 @@ use crate::{ dht_utils::{read_metainfo_from_peer_receiver, ReadMetainfoResult}, peer_connection::PeerConnectionOptions, spawn_utils::{spawn, BlockingSpawner}, - torrent_state::{ManagedTorrent, ManagedTorrentBuilder, ManagedTorrentHandle}, + torrent_state::{ManagedTorrentBuilder, ManagedTorrentHandle}, }; pub const SUPPORTED_SCHEMES: [&str; 3] = ["http:", "https:", "magnet:"]; diff --git a/crates/librqbit/src/torrent_state/initializing.rs b/crates/librqbit/src/torrent_state/initializing.rs index 8d8bc02..0878be6 100644 --- a/crates/librqbit/src/torrent_state/initializing.rs +++ b/crates/librqbit/src/torrent_state/initializing.rs @@ -1,32 +1,19 @@ use std::{ - collections::HashSet, fs::{File, OpenOptions}, - net::SocketAddr, - path::{Path, PathBuf}, sync::Arc, - time::{Duration, Instant}, + time::Instant, }; use anyhow::Context; -use bencode::from_bytes; -use buffers::ByteString; -use librqbit_core::{ - id20::Id20, lengths::Lengths, peer_id::generate_peer_id, speed_estimator::SpeedEstimator, - torrent_metainfo::TorrentMetaV1Info, -}; + +use librqbit_core::{lengths::Lengths, torrent_metainfo::TorrentMetaV1Info}; use parking_lot::Mutex; -use reqwest::Url; + use sha1w::Sha1; use size_format::SizeFormatterBinary as SF; -use tracing::{debug, info, span, warn, Level}; +use tracing::{debug, info, warn}; -use crate::{ - chunk_tracker::ChunkTracker, - file_ops::FileOps, - spawn_utils::{spawn, BlockingSpawner}, - torrent_state::{ManagedTorrent, ManagedTorrentHandle, TorrentStateLive, TorrentStateOptions}, - tracker_comms::{TrackerError, TrackerRequest, TrackerRequestEvent, TrackerResponse}, -}; +use crate::{chunk_tracker::ChunkTracker, file_ops::FileOps}; use super::{paused::TorrentStatePaused, ManagedTorrentInfo}; @@ -64,7 +51,7 @@ impl TorrentStateInitializing { full_path.push(relative_path); std::fs::create_dir_all(full_path.parent().unwrap())?; - let file = if (&self.meta).options.overwrite { + let file = if self.meta.options.overwrite { OpenOptions::new() .create(true) .read(true) @@ -86,12 +73,12 @@ impl TorrentStateInitializing { }; let lengths = - make_lengths(&(&self.meta).info).context("unable to compute Lengths from torrent")?; + make_lengths(&self.meta.info).context("unable to compute Lengths from torrent")?; debug!("computed lengths: {:?}", &lengths); info!("Doing initial checksum validation, this might take a while..."); - let initial_check_results = (&self.meta).spawner.spawn_block_in_place(|| { - FileOps::::new(&(&self.meta).info, &files, &lengths) + let initial_check_results = self.meta.spawner.spawn_block_in_place(|| { + FileOps::::new(&self.meta.info, &files, &lengths) .initial_check(self.only_files.as_deref()) })?; diff --git a/crates/librqbit/src/torrent_state/live/mod.rs b/crates/librqbit/src/torrent_state/live/mod.rs index e59a6d3..b48a206 100644 --- a/crates/librqbit/src/torrent_state/live/mod.rs +++ b/crates/librqbit/src/torrent_state/live/mod.rs @@ -63,8 +63,8 @@ use clone_to_owned::CloneToOwned; use futures::{stream::FuturesUnordered, StreamExt}; use librqbit_core::{ id20::Id20, - lengths::{self, ChunkInfo, Lengths, ValidPieceIndex}, - speed_estimator::{self, SpeedEstimator}, + lengths::{ChunkInfo, Lengths, ValidPieceIndex}, + speed_estimator::{SpeedEstimator}, torrent_metainfo::TorrentMetaV1Info, }; use parking_lot::{Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard}; @@ -88,7 +88,7 @@ use crate::{ peer_connection::{ PeerConnection, PeerConnectionHandler, PeerConnectionOptions, WriterRequest, }, - spawn_utils::{spawn, BlockingSpawner}, + spawn_utils::{spawn}, tracker_comms::{TrackerError, TrackerRequest, TrackerRequestEvent, TrackerResponse}, type_aliases::{PeerHandle, BF}, }; @@ -165,7 +165,7 @@ impl TorrentStateLive { let have_bytes = paused.chunk_tracker.get_have_bytes(); let needed_bytes = paused.chunk_tracker.get_needed_bytes(); - let lengths = paused.chunk_tracker.get_lengths().clone(); + let lengths = *paused.chunk_tracker.get_lengths(); let state = Arc::new(TorrentStateLive { meta: paused.info.clone(), diff --git a/crates/librqbit/src/torrent_state/mod.rs b/crates/librqbit/src/torrent_state/mod.rs index eda146a..04e050f 100644 --- a/crates/librqbit/src/torrent_state/mod.rs +++ b/crates/librqbit/src/torrent_state/mod.rs @@ -7,21 +7,21 @@ use std::net::SocketAddr; use std::path::PathBuf; use std::sync::Arc; use std::time::Duration; -use std::{collections::HashSet, path::Path}; +use std::{path::Path}; use anyhow::Context; use buffers::ByteString; use librqbit_core::id20::Id20; use librqbit_core::peer_id::generate_peer_id; -use librqbit_core::speed_estimator::SpeedEstimator; + use librqbit_core::torrent_metainfo::TorrentMetaV1Info; pub use live::*; use parking_lot::RwLock; -use tokio::sync::mpsc::Sender; -use tracing::trace_span; + + use url::Url; -use crate::spawn_utils::{spawn, BlockingSpawner}; +use crate::spawn_utils::{BlockingSpawner}; use initializing::TorrentStateInitializing; @@ -70,7 +70,7 @@ impl ManagedTorrent { self.info.info_hash } - pub(crate) fn add_peer(&self, peer: SocketAddr) -> bool { + pub(crate) fn add_peer(&self, _peer: SocketAddr) -> bool { todo!() }