diff --git a/CHANGELOG.md b/CHANGELOG.md index 13ab219..65b965c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Dates are given in YYYY-MM-DD format. - PKGBUILD for Arch-based distros - Added Text extension set - More test coverage +- Fixed a very minor output bug relating to scanning symlinked directories ### v0.2.11 (2021-04-04) #### Features diff --git a/Cargo.lock b/Cargo.lock index 2693f39..3ef6050 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ "cfg-if", "crossbeam-utils", @@ -250,9 +250,9 @@ dependencies = [ [[package]] name = "infer" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0803735b9511d0956c68902a6513ca867819d6e43397adb6a5e903e2f09db734" +checksum = "865e8a58ae8e24d2c4412c31344afa1d302a3740ad67528c10f50d6876cdcf55" [[package]] name = "instant" @@ -321,7 +321,7 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mime_guess" version = "2.0.4" -source = "git+https://github.com/Lynnesbian/mime_guess#679d3b8887d30bd43a83f162d61b7226675c7012" +source = "git+https://github.com/Lynnesbian/mime_guess#55fe99663a1b78ad5f50ffe1a9aaeb65fb2cb4ca" dependencies = [ "mime", "unicase", @@ -475,9 +475,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +checksum = "8270314b5ccceb518e7e578952f0b72b88222d02e8f77f5ecf7abbb673539041" dependencies = [ "bitflags", ] diff --git a/Cargo.toml b/Cargo.toml index f9c2329..952a92e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,18 +24,18 @@ infer-backend = [] xdg-mime-backend = [] [dependencies] -walkdir = "2.3.1" +walkdir = "2.3.2" log = "0.4.14" mime_guess = "2.0.3" snailquote = "0.3.0" -once_cell = "1.5.2" -infer = { version = "0.3.4" } +once_cell = "1.7.2" +infer = "0.3.6" rayon = { version = "1.5.0", optional = true } exitcode = "1.1.2" cfg-if = "1.0.0" [target.'cfg(unix)'.dependencies] -xdg-mime = "0.3" +xdg-mime = "0.3.2" [target.'cfg(not(all(target_endian = "big", target_pointer_width = "32")))'.dependencies] smartstring = "0.2.6" @@ -52,7 +52,7 @@ default-features = false features = ["wrap_help", "color", "derive", "std"] [dependencies.env_logger] -version = "0.8.2" +version = "0.8.3" default-features = false features = ["termcolor", "atty"] diff --git a/src/inspectors.rs b/src/inspectors.rs index 980589c..e12e7c8 100644 --- a/src/inspectors.rs +++ b/src/inspectors.rs @@ -117,6 +117,10 @@ cached! { // neither xdg-mime nor infer seem to be able to detect office XML files properly... [vec![String::from("zip"), String::from("docx"), String::from("xlsx"), String::from("pptx")], possible_exts].concat() + } else if mime == Mime::from_str("application/x-ms-dos-executable").unwrap() { + // both .dll and .exe files are given the same mime type... but you definitely don't want to rename one to the + // other! + [vec![String::from("dll"), String::from("exe")], possible_exts].concat() } else { possible_exts }) diff --git a/src/main.rs b/src/main.rs index 5ad0b90..a614f89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,7 @@ // along with this program. If not, see . #![forbid(unsafe_code)] +#![warn(trivial_casts, unused_lifetimes, unused_qualifications)] use std::io::{stdout, BufWriter}; use std::path::Path; @@ -301,7 +302,16 @@ fn scan_directory(dirs: &Path, exts: Option<&Vec<&str>>, scan_opts: &ScanOpts) - } e.ok() }) - .filter(|e| !e.file_type().is_dir()) // remove directories from the final list + // remove directories from the final list + .filter(|e| !e.file_type().is_dir()) + // if fif is invoked without `-f` on a symlinked directory, it will recurse into the symlink (as desired) and ignore + // any symlinks inside the symlinked root directory. however, the root directory will still be added to `entries` as + // if it were a file to be scanned, and `scan_file` will fail to scan it, adding "Failed to read ~/whatever" to the + // output. to avoid this, we can remove all symlinks from `entries` if `-f` is not set. i know this is kind of + // confusing, but it's honestly kind of hard to explain... maybe a screenshot is better: + // https://i.imgur.com/DYG7jlB.png + // adding the symlink filter removes the line that's being pointed to in the image. 0u0 + .filter(|e| scan_opts.follow_symlinks || !e.file_type().is_symlink()) .collect(); if probably_fatal_error {