From 79a523f2fe38110b783564b40f82a19f67163731 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Wed, 1 May 2024 11:51:01 +0100 Subject: [PATCH] Add --experimental-mmap-storage --- crates/rqbit/src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/rqbit/src/main.rs b/crates/rqbit/src/main.rs index 11a33e1..951f6f5 100644 --- a/crates/rqbit/src/main.rs +++ b/crates/rqbit/src/main.rs @@ -7,11 +7,15 @@ use librqbit::{ api::ApiAddTorrentResponse, http_api::{HttpApi, HttpApiOptions}, http_api_client, librqbit_spawn, +<<<<<<< HEAD storage::{ filesystem::FilesystemStorageFactory, middleware::{slow::SlowStorageFactory, timing::TimingStorageFactory}, StorageFactoryExt, }, +======= + storage::mmap::MmapStorageFactory, +>>>>>>> a557afc (Add --experimental-mmap-storage) tracing_subscriber_config_utils::{init_logging, InitLoggingOptions}, AddTorrent, AddTorrentOptions, AddTorrentResponse, Api, ListOnlyResponse, PeerConnectionOptions, Session, SessionOptions, TorrentStatsState, @@ -108,6 +112,10 @@ struct Opts { /// Might be useful if the disk is slow. #[arg(long = "defer-writes", default_value = "false")] defer_writes: bool, + + /// Use mmap (file-backed) for storage. + #[arg(long)] + experimental_mmap_storage: bool, } #[derive(Parser)] @@ -393,11 +401,13 @@ async fn async_main(opts: Opts) -> anyhow::Result<()> { sub_folder: download_opts.sub_folder.clone(), initial_peers: download_opts.initial_peers.clone().map(|p| p.0), disable_trackers: download_opts.disable_trackers, + storage_factory: Some({ let sf = FilesystemStorageFactory::default(); let sf = SlowStorageFactory::new(sf); TimingStorageFactory::new("fs".to_owned(), sf).boxed() }), + ..Default::default() }; let connect_to_existing = match client.validate_rqbit_server().await {