Add --experimental-mmap-storage

This commit is contained in:
Igor Katson 2024-05-01 11:51:01 +01:00
parent ed05ffc6f7
commit 79a523f2fe

View file

@ -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 {