From 8ea2dcc7270a6dfdf0be8176059bb06eeb3ce31e Mon Sep 17 00:00:00 2001 From: matt <30363562+mmattbtw@users.noreply.github.com> Date: Fri, 6 May 2022 22:12:18 -0500 Subject: [PATCH] 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> --- core/src/file/indexer/scan.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/src/file/indexer/scan.rs b/core/src/file/indexer/scan.rs index 546c1918e..31efbb6bf 100644 --- a/core/src/file/indexer/scan.rs +++ b/core/src/file/indexer/scan.rs @@ -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