Skip to content

Commit

Permalink
El capone
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Oct 15, 2023
1 parent 0fe77ed commit 6187741
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
1 change: 0 additions & 1 deletion czkawka_core/i18n/en/czkawka_core.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ core_folder_no_modification_date = Unable to get modification date from folder {
core_missing_no_chosen_included_directory = At least one directory must be provided
core_directory_wildcard_no_supported = Directories: Wildcards in path are not supported, ignoring { $path }
core_directory_relative_path = Directories: Relative path are not supported, ignoring { $path }
core_directory_must_exists = Directories: Provided folder path must exist, ignoring { $path }
core_directory_must_be_directory = Directories: Provided path must point at the directory, ignoring { $path }
core_included_directory_zero_valid_directories = Included Directory ERROR: Not found even one correct path to included which is required
Expand Down
33 changes: 15 additions & 18 deletions czkawka_core/src/common_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ impl Directories {
continue;
}

// If not checking windows strange paths, try to canonicalize them
// Try to canonicalize them
if let Ok(dir) = directory.canonicalize() {
directory = dir;
}
if cfg!(linux) {
directory = PathBuf::from(directory.strip_prefix(r"\\?\").unwrap_or(&directory));
}

checked_directories.push(directory);
}
Expand All @@ -89,7 +92,7 @@ impl Directories {
let directories: Vec<PathBuf> = excluded_directory;

let mut checked_directories: Vec<PathBuf> = Vec::new();
for directory in directories {
for mut directory in directories {
let directory_as_string = directory.to_string_lossy();
if directory_as_string == "/" {
messages.errors.push(flc!("core_excluded_directory_pointless_slash"));
Expand All @@ -102,34 +105,28 @@ impl Directories {
));
continue;
}
#[cfg(not(target_family = "windows"))]
if directory.is_relative() {
messages.warnings.push(flc!(
"core_directory_relative_path",
generate_translation_hashmap(vec![("path", directory.display().to_string())])
));
continue;
}
#[cfg(target_family = "windows")]
if directory.is_relative() && !directory.starts_with("\\") {
messages.warnings.push(flc!(
"core_directory_relative_path",
generate_translation_hashmap(vec![("path", directory.display().to_string())])
));
continue;
}

if !directory.exists() {
// No error when excluded directories are missing
continue;
}

if !directory.is_dir() {
messages.warnings.push(flc!(
"core_directory_must_be_directory",
generate_translation_hashmap(vec![("path", directory.display().to_string())])
));
continue;
}

// Try to canonicalize them
if let Ok(dir) = directory.canonicalize() {
directory = dir;
}
if cfg!(linux) {
directory = PathBuf::from(directory.strip_prefix(r"\\?\").unwrap_or(&directory));
}

checked_directories.push(directory);
}
self.excluded_directories = checked_directories;
Expand Down

0 comments on commit 6187741

Please sign in to comment.