All storage factories are generic now
This commit is contained in:
parent
e4adfa569a
commit
5027d8ccd1
12 changed files with 88 additions and 52 deletions
|
|
@ -8,7 +8,11 @@ use anyhow::Context;
|
|||
use size_format::SizeFormatterBinary as SF;
|
||||
use tracing::{debug, info, warn};
|
||||
|
||||
use crate::{chunk_tracker::ChunkTracker, file_ops::FileOps, storage::StorageFactory};
|
||||
use crate::{
|
||||
chunk_tracker::ChunkTracker,
|
||||
file_ops::FileOps,
|
||||
storage::{BoxStorageFactory, StorageFactory},
|
||||
};
|
||||
|
||||
use super::{paused::TorrentStatePaused, ManagedTorrentInfo};
|
||||
|
||||
|
|
@ -34,7 +38,7 @@ impl TorrentStateInitializing {
|
|||
|
||||
pub async fn check(
|
||||
&self,
|
||||
storage_factory: &dyn StorageFactory,
|
||||
storage_factory: &BoxStorageFactory,
|
||||
) -> anyhow::Result<TorrentStatePaused> {
|
||||
let files = storage_factory.init_storage(&self.meta)?;
|
||||
info!("Doing initial checksum validation, this might take a while...");
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ use tracing::warn;
|
|||
use crate::chunk_tracker::ChunkTracker;
|
||||
use crate::file_info::FileInfo;
|
||||
use crate::spawn_utils::BlockingSpawner;
|
||||
use crate::storage::StorageFactory;
|
||||
use crate::storage::BoxStorageFactory;
|
||||
use crate::torrent_state::stats::LiveStats;
|
||||
use crate::type_aliases::FileInfos;
|
||||
use crate::type_aliases::PeerStream;
|
||||
|
|
@ -108,7 +108,7 @@ pub struct ManagedTorrentInfo {
|
|||
|
||||
pub struct ManagedTorrent {
|
||||
pub info: Arc<ManagedTorrentInfo>,
|
||||
pub(crate) storage_factory: Box<dyn StorageFactory>,
|
||||
pub(crate) storage_factory: BoxStorageFactory,
|
||||
|
||||
state_change_notify: Notify,
|
||||
locked: RwLock<ManagedTorrentLocked>,
|
||||
|
|
@ -273,7 +273,7 @@ impl ManagedTorrent {
|
|||
error_span!(parent: span.clone(), "initialize_and_start"),
|
||||
token.clone(),
|
||||
async move {
|
||||
match init.check(&*t.storage_factory).await {
|
||||
match init.check(&t.storage_factory).await {
|
||||
Ok(paused) => {
|
||||
let mut g = t.locked.write();
|
||||
if let ManagedTorrentState::Initializing(_) = &g.state {
|
||||
|
|
@ -504,7 +504,7 @@ pub(crate) struct ManagedTorrentBuilder {
|
|||
peer_id: Option<Id20>,
|
||||
spawner: Option<BlockingSpawner>,
|
||||
allow_overwrite: bool,
|
||||
storage_factory: Box<dyn StorageFactory>,
|
||||
storage_factory: BoxStorageFactory,
|
||||
}
|
||||
|
||||
impl ManagedTorrentBuilder {
|
||||
|
|
@ -512,7 +512,7 @@ impl ManagedTorrentBuilder {
|
|||
info: TorrentMetaV1Info<ByteBufOwned>,
|
||||
info_hash: Id20,
|
||||
output_folder: PathBuf,
|
||||
storage_factory: Box<dyn StorageFactory>,
|
||||
storage_factory: BoxStorageFactory,
|
||||
) -> Self {
|
||||
Self {
|
||||
info,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue