Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
4am code moments
Browse files Browse the repository at this point in the history
  • Loading branch information
maikirakiwi committed Jul 10, 2022
1 parent a51e64a commit ba20589
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cider_utils"
version = "0.1.0"
version = "0.1.4"
license = "AGPL-3.0"
edition = "2021"
exclude = ["index.node"]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cider_utils",
"version": "0.1.2",
"version": "0.1.4",
"description": "",
"main": "index.js",
"files": [
Expand Down
11 changes: 5 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main(mut cx: ModuleContext) -> NeonResult<()> {
}

pub fn file_extension_parser(filename: &str) -> Option<&str> {
Path::new(filename).extension().and_then(OsStr::to_str)
return Path::new(filename).extension().and_then(OsStr::to_str)
}

// Stolen from official Neon docs.
Expand All @@ -40,14 +40,13 @@ pub fn recursive_folder_search(mut cx: FunctionContext) -> JsResult<JsObject> {

for file in WalkDir::new(arg.value(&mut cx)).follow_links(true).into_iter().filter_map(|e| e.ok()) {
let file_name_ascii_lowercase = file.file_name().to_ascii_lowercase();
let file_name_str = file_extension_parser(file_name_ascii_lowercase.to_str().unwrap());
match file_name_str.unwrap() {
"mp3" | "flac" | "wav" | "opus" => parse_file_vec.push(file_name_ascii_lowercase.to_str().unwrap().to_owned()),
"aac" | "m4a" | "ogg" | "webm" => music_metadata_vec.push(file_name_ascii_lowercase.to_str().unwrap().to_owned()),
let file_ext_str = file_extension_parser(file_name_ascii_lowercase.to_str().unwrap());
match file_ext_str {
Some("mp3" | "flac" | "wav" | "opus") => parse_file_vec.push(file.file_name().to_str().unwrap().to_owned()),
Some("aac" | "m4a" | "ogg" | "webm") => music_metadata_vec.push(file.file_name().to_str().unwrap().to_owned()),
_ => continue,
};
}

let result_obj: Handle<JsObject> = cx.empty_object();
let parse_file_array = vec_to_array(&parse_file_vec, &mut cx).unwrap();
let mm_file_array = vec_to_array(&music_metadata_vec, &mut cx).unwrap();
Expand Down

0 comments on commit ba20589

Please sign in to comment.