make directories not have extensions (#83)

* fix: #78

* Update core/src/file/indexer/scan.rs

Co-authored-by: maxichrome <33473181+maxichrome@users.noreply.github.com>

Co-authored-by: maxichrome <33473181+maxichrome@users.noreply.github.com>
This commit is contained in:
matt
2022-05-06 22:12:18 -05:00
committed by GitHub
parent 626fb02035
commit 8ea2dcc727

View File

@@ -172,8 +172,20 @@ fn prepare_values(
let metadata = fs::metadata(&file_path)?;
let location_path = location.path.as_ref().unwrap().as_str();
// let size = metadata.len();
let name = extract_name(file_path.file_stem());
let extension = extract_name(file_path.extension());
let name;
let extension;
// if the 'file_path' is not a directory, then get the extension and name.
// if 'file_path' is a directory, set extension to an empty string to avoid periods in folder names
// - being interpreted as file extensions
if file_path.is_dir() {
extension = "".to_string();
name = extract_name(file_path.file_name());
} else {
extension = extract_name(file_path.extension());
name = extract_name(file_path.file_stem());
}
let materialized_path = match file_path.to_str() {
Some(p) => p