saving
This commit is contained in:
parent
0aa1af7933
commit
5e728fc67b
5 changed files with 23 additions and 36 deletions
|
|
@ -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<String> {
|
||||
fn api_dump_haves(&self, _idx: usize) -> Result<String> {
|
||||
Err(anyhow::anyhow!("not implemented").into())
|
||||
// let mgr = self.mgr_handle(idx)?;
|
||||
// Ok(format!(
|
||||
|
|
|
|||
|
|
@ -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:"];
|
||||
|
|
|
|||
|
|
@ -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::<Sha1>::new(&(&self.meta).info, &files, &lengths)
|
||||
let initial_check_results = self.meta.spawner.spawn_block_in_place(|| {
|
||||
FileOps::<Sha1>::new(&self.meta.info, &files, &lengths)
|
||||
.initial_check(self.only_files.as_deref())
|
||||
})?;
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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!()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue