-
Notifications
You must be signed in to change notification settings - Fork 31
Du updates #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Du updates #478
+542
−69
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes Applied to tree/du.rs 1. Fixed -a option bug - Files now only print when -a is specified (was incorr 2. Implemented -x option - Tracks initial device ID and skips files on differe 3. Implemented hard link deduplication - Tracks (dev, ino) pairs; files with 4. Fixed file operand handling - Non-directory file operands are now always li Tests Added to tree/tests/du/mod.rs - test_du_basic - Enhanced existing test - test_du_default_no_files - Verifies default doesn't list files - test_du_kilo - Tests -k option (1024-byte units) - test_du_nonexistent - Tests error handling for missing files - test_du_file_operand - Tests file operand always listed - test_du_symlink_h - Tests -H follows cmdline symlinks - test_du_symlink_l - Tests -L follows all symlinks - test_du_hardlink - Tests hard links counted once
There was a problem hiding this comment.
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 adds comprehensive test coverage for the du (disk usage) utility and implements missing POSIX features that were previously marked as TODO items.
Key Changes:
- Implements
-H(follow command-line symlinks),-L(dereference all symlinks), and-x(one filesystem) options - Adds hard link deduplication to prevent counting the same file multiple times
- Adds 8 comprehensive integration tests covering basic functionality, default behavior, options, error handling, symlinks, and hard links
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tree/tests/tree-tests.rs | Adds module declaration for new du tests |
| tree/tests/du/mod.rs | New file containing 8 comprehensive integration tests for du utility functionality |
| tree/du.rs | Complete rewrite of du implementation using ftw::traverse_directory with support for -H, -L, -x options and hard link deduplication |
| Cargo.lock | Minor dependency version updates (bumpalo, cc, libredox, ntapi, portable-atomic, toml_*, tracing) |
Summary of Changes
1. tree/du.rs (already present from earlier fix)
Fixed directory block counting - directories were being double-counted (once w
2. tree/tests/du/mod.rs (my fix)
Root Cause: The test directory test_du_symlink_l contains "link" in its name.
- 8 .../test_du_symlink_l/subdir/link (actual symlink)
- 16 .../test_du_symlink_l/subdir (directory - contains "link" in path!
Fix: Changed line.contains("link") to line.ends_with("/link") so it only match
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.