Skip to content

find: share output files across actions - #846

Open
ruidosujeira wants to merge 1 commit into
uutils:mainfrom
ruidosujeira:fix/777-shared-output-file
Open

find: share output files across actions#846
ruidosujeira wants to merge 1 commit into
uutils:mainfrom
ruidosujeira:fix/777-shared-output-file

Conversation

@ruidosujeira

Copy link
Copy Markdown

Fixes #777.

Summary

  • Open and truncate each output path only once while building the matcher tree.
  • Reuse cloned file handles so -fprint, -fprintf, -fprint0, and -fls share the same file cursor.
  • Prevent multiple output actions targeting the same file from overwriting each other's data.
  • Add a regression test combining -fprintf and -fprint0 with the same output file.

Testing

  • cargo test --lib --test test_find
  • cargo fmt --all -- --check

All 234 unit tests and 71 find integration tests pass.

Copilot AI lite review requested due to automatic review settings August 20, 2026 02:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a find output corruption bug when multiple output actions (e.g., -fprintf and -fprint0) target the same output file by ensuring those actions share a single underlying file cursor rather than independently truncating/overwriting the file.

Changes:

  • Thread an output_files map through matcher-tree construction to open/truncate each output path only once and reuse cloned handles.
  • Update -fprint, -fprintf, -fprint0, and -fls to use the shared output-file handle logic.
  • Add an integration regression test that combines -fprintf and -fprint0 writing to the same output file and asserts correct concatenated output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/find/matchers/mod.rs Cache output File handles by path during matcher construction and return cloned handles that share the same cursor across output actions.
tests/test_find.rs Add regression coverage verifying -fprintf and -fprint0 can safely share the same output file without truncation/overwrites.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.29%. Comparing base (f5f0f64) to head (104a111).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/find/matchers/mod.rs 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #846      +/-   ##
==========================================
+ Coverage   92.27%   92.29%   +0.01%     
==========================================
  Files          35       35              
  Lines        7435     7447      +12     
  Branches      386      387       +1     
==========================================
+ Hits         6861     6873      +12     
  Misses        433      433              
  Partials      141      141              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq

codspeed-hq Bot commented Aug 20, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 14.66%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 19 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
printf 31.6 ms 37.1 ms -14.66%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ruidosujeira:fix/777-shared-output-file (104a111) with main (f5f0f64)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(find): when combining -fprintf and -fprint0 with the same file will lead to a corruption

2 participants