diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2022-05-12 08:40:10 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2022-05-12 08:40:10 +0800 |
commit | 157b43c2cb203c067c66f499a9fd849e5f0e811c (patch) | |
tree | 4d05a766aee6eda90475f7e06623f4328bce361d | |
parent | 1f852ed5afd118d1f4804baf0574189f4d1f0b42 (diff) | |
parent | 8742232a15c2bdd608c2e2c731a786c59c7d58dc (diff) |
Merge branch 'broken-link-handling'
-rw-r--r-- | src/aggregate.rs | 10 | ||||
-rw-r--r-- | src/traverse.rs | 8 | ||||
-rw-r--r-- | tests/snapshots/failure-no-arguments-multiple-input-paths-some-not-existing | 7 | ||||
-rw-r--r-- | tests/snapshots/success-no-arguments-multiple-input-paths-one-broken-link | 6 | ||||
-rwxr-xr-x | tests/stateless-journey.sh | 8 |
5 files changed, 36 insertions, 3 deletions
diff --git a/src/aggregate.rs b/src/aggregate.rs index 2b621d9..9a2c518 100644 --- a/src/aggregate.rs +++ b/src/aggregate.rs @@ -88,7 +88,15 @@ pub fn aggregate( num_roots += 1; let mut num_bytes = 0u128; let mut num_errors = 0u64; - let device_id = crossdev::init(path.as_ref())?; + let device_id = match crossdev::init(path.as_ref()) { + Ok(id) => id, + Err(_) => { + num_errors += 1; + res.num_errors += 1; + aggregates.push((path.as_ref().to_owned(), num_bytes, num_errors)); + continue; + } + }; for entry in walk_options.iter_from_path(path.as_ref()) { stats.entries_traversed += 1; progress.throttled(|out| { diff --git a/src/traverse.rs b/src/traverse.rs index 7cdaf7f..1bbece4 100644 --- a/src/traverse.rs +++ b/src/traverse.rs @@ -95,7 +95,13 @@ impl Traversal { for path in input.into_iter() { let mut last_seen_eid = 0; - let device_id = crossdev::init(path.as_ref())?; + let device_id = match crossdev::init(path.as_ref()) { + Ok(id) => id, + Err(_) => { + t.io_errors += 1; + continue; + } + }; for (eid, entry) in walk_options .iter_from_path(path.as_ref()) .into_iter() diff --git a/tests/snapshots/failure-no-arguments-multiple-input-paths-some-not-existing b/tests/snapshots/failure-no-arguments-multiple-input-paths-some-not-existing index 59f080a..30c4a97 100644 --- a/tests/snapshots/failure-no-arguments-multiple-input-paths-some-not-existing +++ b/tests/snapshots/failure-no-arguments-multiple-input-paths-some-not-existing @@ -1 +1,6 @@ -Error: No such file or directory (os error 2)
\ No newline at end of file + 0 B foo <1 IO Error> + 0 B bar <1 IO Error> + 0 B baz <1 IO Error> + 1.28 MB . + 1.28 MB . + 2.56 MB total <3 IO Errors>
\ No newline at end of file diff --git a/tests/snapshots/success-no-arguments-multiple-input-paths-one-broken-link b/tests/snapshots/success-no-arguments-multiple-input-paths-one-broken-link new file mode 100644 index 0000000..4c99a22 --- /dev/null +++ b/tests/snapshots/success-no-arguments-multiple-input-paths-one-broken-link @@ -0,0 +1,6 @@ + 0 B broken-link <1 IO Error> + 258.05 KB ./dir/sub + 1.27 MB dir + 1.28 MB . + 2.81 MB total <1 IO Error> +Statistics { entries_traversed: 25, smallest_file_in_bytes: 0, largest_file_in_bytes: 1003520 }
\ No newline at end of file diff --git a/tests/stateless-journey.sh b/tests/stateless-journey.sh index c5a11bd..37a32c2 100755 --- a/tests/stateless-journey.sh +++ b/tests/stateless-journey.sh @@ -65,6 +65,14 @@ WITH_FAILURE=1 expect_run ${SUCCESSFULLY} "$exe" aggregate --stats . . dir ./dir/ ./dir/sub } ) + (with "a broken link in multiple roots" + ln -s not-present broken-link + it "fails but lists valid paths" && { + WITH_SNAPSHOT="$snapshot/success-no-arguments-multiple-input-paths-one-broken-link" \ + expect_run ${WITH_FAILURE} "$exe" aggregate --stats . dir broken-link ./dir/sub + } + rm broken-link + ) ) (when "specifying no subcommand" it "produces a human-readable aggregate" && { |