mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Fix -x option behavior
This PR addresses an issue where `target_dirs` were being optimized out\ before being passed to the `get_filesystem_devices()` function. The changes in this PR ensure that `target_dirs` are passed directly to `get_filesystem_devices()`, and only then are they simplified. Example of a command that currently doesn't work correctly: ```sh dust -x $(findmnt -S tmpfs -o target -n) ``` It should show the usage of all tmpfs mounts, but it currently shows just the the root mountpoints like `/run`, since all the mountpoints nested under it are optimized out.
This commit is contained in:
committed by
andy.boot
parent
3f2f7a8bb2
commit
58c9f6d509
+2
-2
@@ -192,10 +192,10 @@ fn main() {
|
|||||||
let limit_filesystem = options.get_flag("limit_filesystem");
|
let limit_filesystem = options.get_flag("limit_filesystem");
|
||||||
let follow_links = options.get_flag("dereference_links");
|
let follow_links = options.get_flag("dereference_links");
|
||||||
|
|
||||||
let simplified_dirs = simplify_dir_names(target_dirs);
|
|
||||||
let allowed_filesystems = limit_filesystem
|
let allowed_filesystems = limit_filesystem
|
||||||
.then(|| get_filesystem_devices(simplified_dirs.iter()))
|
.then(|| get_filesystem_devices(target_dirs.iter().cloned()))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
let simplified_dirs = simplify_dir_names(target_dirs);
|
||||||
|
|
||||||
let ignored_full_path: HashSet<PathBuf> = ignore_directories
|
let ignored_full_path: HashSet<PathBuf> = ignore_directories
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|||||||
+3
-2
@@ -34,11 +34,12 @@ pub fn simplify_dir_names<P: AsRef<Path>>(filenames: Vec<P>) -> HashSet<PathBuf>
|
|||||||
top_level_names
|
top_level_names
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_filesystem_devices<'a, P: IntoIterator<Item = &'a PathBuf>>(paths: P) -> HashSet<u64> {
|
pub fn get_filesystem_devices<'a, P: IntoIterator<Item = &'a str>>(paths: P) -> HashSet<u64> {
|
||||||
// Gets the device ids for the filesystems which are used by the argument paths
|
// Gets the device ids for the filesystems which are used by the argument paths
|
||||||
paths
|
paths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|p| match get_metadata(p, false) {
|
.map(PathBuf::from)
|
||||||
|
.filter_map(|p| match get_metadata(&p, false) {
|
||||||
Some((_size, Some((_id, dev)), _time)) => Some(dev),
|
Some((_size, Some((_id, dev)), _time)) => Some(dev),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user