Skip to content

Conversation

@Xylphy
Copy link
Contributor

@Xylphy Xylphy commented Jan 13, 2026

Closes #10193

This pull request refactors error handling in the tail_file function in src/uu/tail/src/tail.rs to use path.metadata() for file checks and improves error reporting formatting.

Error handling and logic improvements:

  • Changed file existence and directory checks to use path.metadata(), enabling more robust detection of missing files and directories. This replaces separate checks for existence and directory status with a single match statement.
  • Added explicit handling for ErrorKind::NotFound to ensure missing files are reported with the correct error message and observer update, then exit early.

Error reporting formatting:

  • Updated error message formatting to use multi-line translate! calls for better readability and consistency across permission and file opening errors.

@Xylphy Xylphy changed the title Fix(tail): Handle missing/dir paths via metadata() tail: Handle missing/dir paths via metadata() Jan 13, 2026
Add Unix-only tests covering the case where probing a path (e.g. via metadata)
fails with PermissionDenied (directory not searchable). Ensure we report
"Permission denied" rather than "No such file or directory", matching GNU tail.
@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/fmt/non-space. tests/fmt/non-space is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)

@sylvestre
Copy link
Contributor

please fix the jobs

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 18, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 3.28%

Comparing Xylphy:tail-metadata-error-handling (fdf95f9) with main (2122c52)1

Summary

❌ 1 regressed benchmark
✅ 281 untouched benchmarks
⏩ 38 skipped benchmarks2

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory dd_copy_partial 129.1 KB 133.5 KB -3.28%

Footnotes

  1. No successful run was found on main (1a81d1b) during the generation of this report, so 2122c52 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 38 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Xylphy
Copy link
Contributor Author

Xylphy commented Jan 19, 2026

@sylvestre Done!

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.

tail: exists precheck masks permission errors

2 participants