mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-06 03:25:23 +00:00
refactor: drop dependency to the ignore
crate (#493)
This commit is contained in:
parent
f887a2390e
commit
cc27b5ec6b
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -1001,22 +1001,6 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ignore"
|
|
||||||
version = "0.4.23"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b"
|
|
||||||
dependencies = [
|
|
||||||
"crossbeam-deque",
|
|
||||||
"globset",
|
|
||||||
"log",
|
|
||||||
"memchr",
|
|
||||||
"regex-automata 0.4.9",
|
|
||||||
"same-file",
|
|
||||||
"walkdir",
|
|
||||||
"winapi-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "image"
|
name = "image"
|
||||||
version = "0.25.6"
|
version = "0.25.6"
|
||||||
@ -2225,7 +2209,6 @@ dependencies = [
|
|||||||
"directories",
|
"directories",
|
||||||
"gag",
|
"gag",
|
||||||
"human-panic",
|
"human-panic",
|
||||||
"ignore",
|
|
||||||
"image",
|
"image",
|
||||||
"nom",
|
"nom",
|
||||||
"nucleo",
|
"nucleo",
|
||||||
|
@ -48,7 +48,6 @@ ratatui = { version = "0.29", features = ["serde", "macros"] }
|
|||||||
better-panic = "0.3"
|
better-panic = "0.3"
|
||||||
signal-hook = "0.3"
|
signal-hook = "0.3"
|
||||||
human-panic = "2.0"
|
human-panic = "2.0"
|
||||||
ignore = "0.4"
|
|
||||||
strum = { version = "0.26", features = ["derive"] }
|
strum = { version = "0.26", features = ["derive"] }
|
||||||
regex = "1.11"
|
regex = "1.11"
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12"
|
||||||
|
@ -5,10 +5,8 @@ use std::io::BufRead;
|
|||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
use ignore::{overrides::Override, types::TypesBuilder, WalkBuilder};
|
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
use crate::utils::strings::{
|
use crate::utils::strings::{
|
||||||
@ -67,38 +65,6 @@ pub fn get_default_num_threads() -> usize {
|
|||||||
*DEFAULT_NUM_THREADS.get_or_init(default_num_threads)
|
*DEFAULT_NUM_THREADS.get_or_init(default_num_threads)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_builder(
|
|
||||||
path: &Path,
|
|
||||||
n_threads: usize,
|
|
||||||
overrides: Option<Override>,
|
|
||||||
ignore_paths: Option<Vec<PathBuf>>,
|
|
||||||
) -> WalkBuilder {
|
|
||||||
let mut builder = WalkBuilder::new(path);
|
|
||||||
|
|
||||||
// ft-based filtering
|
|
||||||
let mut types_builder = TypesBuilder::new();
|
|
||||||
types_builder.add_defaults();
|
|
||||||
builder.types(types_builder.build().unwrap());
|
|
||||||
|
|
||||||
// ignore paths
|
|
||||||
if let Some(paths) = ignore_paths {
|
|
||||||
builder.filter_entry(move |e| {
|
|
||||||
let path = e.path();
|
|
||||||
if paths.iter().any(|p| path.starts_with(p)) {
|
|
||||||
debug!("Ignoring path: {:?}", path);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.threads(n_threads);
|
|
||||||
if let Some(ov) = overrides {
|
|
||||||
builder.overrides(ov);
|
|
||||||
}
|
|
||||||
builder
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_file_size(path: &Path) -> Option<u64> {
|
pub fn get_file_size(path: &Path) -> Option<u64> {
|
||||||
std::fs::metadata(path).ok().map(|m| m.len())
|
std::fs::metadata(path).ok().map(|m| m.len())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user