Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.5k
rm: Implement --one-file-system and --preserve-root=all#7569
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
src/uu/rm/src/rm.rs Outdated
match validate_single_filesystem(path) { | ||
Ok(()) => true, | ||
Err(additional_reason) => { | ||
if !additional_reason.is_empty() { | ||
show_error!("{}", additional_reason); | ||
} | ||
show_error!( | ||
"skipping {}, since it's on a different device", | ||
path.quote() | ||
); | ||
if options.preserve_root == PreserveRoot::YesAll { | ||
show_error!("and --preserve-root=all is in effect"); | ||
} | ||
false | ||
} | ||
} |
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.
can probably be simplified with something like:
matchvalidate_single_filesystem(path){ | |
Ok(()) =>true, | |
Err(additional_reason) =>{ | |
if !additional_reason.is_empty(){ | |
show_error!("{}", additional_reason); | |
} | |
show_error!( | |
"skipping {}, since it's on a different device", | |
path.quote() | |
); | |
if options.preserve_root ==PreserveRoot::YesAll{ | |
show_error!("and --preserve-root=all is in effect"); | |
} | |
false | |
} | |
} | |
let result =validate_single_filesystem(path); | |
if result.is_ok(){ | |
returntrue; | |
} | |
ifletErr(additional_reason) = result{ | |
if !additional_reason.is_empty(){ | |
show_error!("{}", additional_reason); | |
} | |
} | |
show_error!( | |
"skipping {}, since it's on a different device", | |
path.quote() | |
); | |
if options.preserve_root ==PreserveRoot::YesAll{ | |
show_error!("and --preserve-root=all is in effect"); | |
} | |
false |
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.
Thank you for pointing that out! I've implemented the suggested simplification.
GNU testsuite comparison:
|
some jobs are failing :) |
GNU testsuite comparison:
|
GNU testsuite comparison:
|
does |
GNU testsuite comparison:
|
The following is the test result. It has passed.
|
I tried again and it failed, so I will fix it.
|
GNU testsuite comparison:
|
GNU testsuite comparison:
|
GNU testsuite comparison:
|
Sorry, i think i made a mistake with the conflict resolution :( could you please fix it? thanks |
No warries, I'll fix it. |
- Implement --one-file-system option logic- Add mount point detection and filesystem validation- Create helper functions to check and validate filesystem boundaries- Prevent recursive removal across different filesystem devices
- Add PreserveRoot enum to replace boolean preserve_root option- Extend preserve-root functionality with 'all' and 'no' modes- Update preserve-root option parsing- Remove TODO comment for one-file-system implementation
- Restructured the function to separate result handling and error reporting- Fixed a typo in the comment ("neigher" -> "neither")- Simplified the match statement with a more linear control flow
- Update test_rm_one_file_system and test_rm_preserve_root to use relative paths (fs.img, fs) instead of hardcoded /tmp paths.- Enhance cleanup logic by ensuring all temporary files and directories, including mount points, are removed after tests.
- Set `mount_dir` in Windows- Modify the `new` function of the `Filesystem` accordingly to reflect these changes
- Eliminated unnecessary `PathBuf` import in `features/fsext.rs`.- Replaced `unwrap_or(PathBuf::new())` with the more idiomatic `unwrap_or_default()`.
- Removed platform-specific branching for the `delay` variable- Increased delay time to address insufficient wait periods during test execution
- Rename `validate_single_filesystem` to `check_one_fs` for improved clarity and alignment with its functionality.- Refactore `check_one_fs` to directly handle options such as `--one-file-system` and `--preserve-root=all` and return detailed error messages when the conditions are not met.- Integrate `check_one_fs` into `remove_dir_recursive` and `handle_dir` for consistent handling of files and directories on different file systems.
- Reorder the call to `check_one_fs` within `remove_dir_recursive` for better structure and logical flow.- Update comment descriptions to match the new sequence of operations.
GNU testsuite comparison:
|
Uh oh!
There was an error while loading.Please reload this page.
Fixes#7011
Implement
--one-file-system
and--preserve-root=all
options for therm
command.