Skip to content

Commit

Permalink
ntfs2ntfs: ability to disable transfers computing
Browse files Browse the repository at this point in the history
  • Loading branch information
patochectp committed Mar 13, 2024
1 parent e7bbf0a commit 13e39c7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
22 changes: 15 additions & 7 deletions ntfs2ntfs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
19 changes: 19 additions & 0 deletions ntfs2ntfs/tests/ntfs2ntfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit 13e39c7

Please sign in to comment.