Skip to content

Commit

Permalink
Also regree
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Oct 15, 2023
1 parent de408a1 commit 6078c82
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion czkawka_core/src/common_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,33 @@ impl Directories {
}

pub fn set_reference_directory(&mut self, reference_directory: Vec<PathBuf>) {
self.reference_directories = reference_directory;
self.reference_directories = reference_directory
.iter()
.map(|d| {
let mut directory = d.clone();
if directory.to_string_lossy().contains('*') {
return None;
}

if !directory.exists() {
return None;
}
if !directory.is_dir() {
return None;
}

// Try to canonicalize them
if let Ok(dir) = directory.canonicalize() {
directory = dir;
}
if cfg!(windows) {
directory = PathBuf::from(directory.strip_prefix(r"\\?\").unwrap_or(&directory));
}
Some(directory)
})
.filter(|d| d.is_some())
.map(|d| d.unwrap())
.collect::<Vec<PathBuf>>();
}

pub fn set_included_directory(&mut self, included_directory: Vec<PathBuf>) -> Messages {
Expand Down

0 comments on commit 6078c82

Please sign in to comment.