From 13e39c7daf5224a9a32ce86c40430540ea714b02 Mon Sep 17 00:00:00 2001 From: patoche Date: Wed, 13 Mar 2024 14:50:43 +0100 Subject: [PATCH 1/2] ntfs2ntfs: ability to disable transfers computing --- ntfs2ntfs/src/main.rs | 22 +++++++++++++++------- ntfs2ntfs/tests/ntfs2ntfs.rs | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/ntfs2ntfs/src/main.rs b/ntfs2ntfs/src/main.rs index 88aa7050f..65d611e56 100644 --- a/ntfs2ntfs/src/main.rs +++ b/ntfs2ntfs/src/main.rs @@ -64,6 +64,10 @@ struct Opt { /// Waiting time at stop in seconds. #[arg(long, short = 't', default_value = transit_model::TRANSFER_WAITING_TIME)] waiting_time: u32, + + /// Don't compute transfers even the transfers of the stop point to itself (max_distance = 0.0) + #[arg(long)] + ignore_transfers: bool, } fn init_logger() { @@ -89,13 +93,17 @@ fn run(opt: Opt) -> Result<()> { info!("Launching ntfs2ntfs..."); let model = transit_model::ntfs::read(opt.input)?; - let model = generates_transfers( - model, - opt.max_distance, - opt.walking_speed, - opt.waiting_time, - None, - )?; + let model = if opt.ignore_transfers { + model + } else { + generates_transfers( + model, + opt.max_distance, + opt.walking_speed, + opt.waiting_time, + None, + )? + }; if let Some(output) = opt.output { match output.extension() { diff --git a/ntfs2ntfs/tests/ntfs2ntfs.rs b/ntfs2ntfs/tests/ntfs2ntfs.rs index 90882c591..56c358661 100644 --- a/ntfs2ntfs/tests/ntfs2ntfs.rs +++ b/ntfs2ntfs/tests/ntfs2ntfs.rs @@ -70,3 +70,22 @@ fn test_ntfs2ntfs_create_foobar() { .success(); assert!(ntfs_foobar.join("feed_infos.txt").is_file()); } + +#[test] +fn test_ntfs2ntfs_without_transfers() { + let output_dir = TempDir::new().expect("create temp dir failed"); + Command::cargo_bin("ntfs2ntfs") + .expect("Failed to find binary 'ntfs2ntfs'") + .arg("--input") + .arg("../tests/fixtures/minimal_ntfs/") + .arg("--output") + .arg(output_dir.path().to_str().unwrap()) + .arg("--current-datetime") + .arg("2019-04-03T17:19:00Z") + .arg("--ignore-transfers") + .assert() + .success(); + assert!(output_dir.path().join("feed_infos.txt").is_file()); + let collections = transit_model::ntfs::read(output_dir).unwrap(); + assert_eq!(0, collections.transfers.len()); +} From 7a59d821c878b67224fdb5ca500a66be1b928d94 Mon Sep 17 00:00:00 2001 From: patoche Date: Wed, 13 Mar 2024 14:52:28 +0100 Subject: [PATCH 2/2] bump version 0.62.2 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 56a9e0580..7fb61d81c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Hove ", "Guillaume Pinot "] name = "transit_model" -version = "0.62.1" +version = "0.62.2" license = "AGPL-3.0-only" description = "Transit data management" repository = "https://github.com/hove-io/transit_model"