mirror of
https://github.com/sreedevk/deduplicator.git
synced 2026-08-26 02:04:39 +00:00
count graphemes instead of chars in path length check
This commit is contained in:
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -290,6 +290,7 @@ dependencies = [
|
|||||||
"rayon",
|
"rayon",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"threadpool",
|
"threadpool",
|
||||||
|
"unicode-segmentation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -898,6 +899,12 @@ version = "1.0.18"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-segmentation"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-width"
|
name = "unicode-width"
|
||||||
version = "0.1.14"
|
version = "0.1.14"
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ prettytable-rs = "0.10.0"
|
|||||||
rand = "0.9.1"
|
rand = "0.9.1"
|
||||||
rayon = "1.6.1"
|
rayon = "1.6.1"
|
||||||
threadpool = "1.8.1"
|
threadpool = "1.8.1"
|
||||||
|
unicode-segmentation = "1.12.0"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
strip = true
|
strip = true
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ const RESET: &str = "\x1b[0m";
|
|||||||
|
|
||||||
pub struct Formatter;
|
pub struct Formatter;
|
||||||
impl Formatter {
|
impl Formatter {
|
||||||
pub fn human_path(file: &FileInfo, aargs: &Params, min_path_length: usize) -> Result<String> {
|
pub fn human_path(file: &FileInfo, aargs: &Params, max_path_length: usize) -> Result<String> {
|
||||||
let base_directory: PathBuf = aargs.get_directory()?;
|
let base_directory: PathBuf = aargs.get_directory()?;
|
||||||
let relative_path = diff_paths(&file.path, base_directory).unwrap_or_default();
|
let relative_path = diff_paths(&file.path, base_directory).unwrap_or_default();
|
||||||
|
|
||||||
let formatted_path = format!(
|
let formatted_path = format!(
|
||||||
"{:<0width$}",
|
"{:<0width$}",
|
||||||
relative_path.to_str().unwrap_or_default().to_string(),
|
relative_path.to_str().unwrap_or_default().to_string(),
|
||||||
width = min_path_length
|
width = max_path_length
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(formatted_path)
|
Ok(formatted_path)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use rayon::prelude::{IntoParallelIterator, ParallelIterator};
|
|||||||
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
||||||
use std::sync::{Arc, Mutex, TryLockError, TryLockResult};
|
use std::sync::{Arc, Mutex, TryLockError, TryLockResult};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
use crate::fileinfo::FileInfo;
|
use crate::fileinfo::FileInfo;
|
||||||
use crate::params::Params;
|
use crate::params::Params;
|
||||||
@@ -64,7 +65,7 @@ impl Processor {
|
|||||||
|
|
||||||
Self::compare_and_update_max_path_len(
|
Self::compare_and_update_max_path_len(
|
||||||
max_file_size.clone(),
|
max_file_size.clone(),
|
||||||
file.path.to_string_lossy().len() as u64,
|
file.path.to_string_lossy().graphemes(true).count() as u64,
|
||||||
);
|
);
|
||||||
|
|
||||||
hw_store
|
hw_store
|
||||||
|
|||||||
Reference in New Issue
Block a user