-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(redacted): check if files exceed redacteds allowed path limit
- Loading branch information
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ pub mod client; | |
pub mod constants; | ||
pub mod error; | ||
pub mod model; | ||
pub mod path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::fs::util::get_all_files_with_extension; | ||
use std::path::PathBuf; | ||
|
||
const REDACTED_MAX_LENGTH: usize = 180; | ||
|
||
pub async fn is_path_exceeding_redacted_path_limit(folder_path: &PathBuf) -> anyhow::Result<bool> { | ||
let folder_name = folder_path.file_name().unwrap().to_str().unwrap(); | ||
|
||
let dir = get_all_files_with_extension(folder_path, ".flac").await?; | ||
|
||
for flac_path in dir { | ||
let flac_name = flac_path.file_name().unwrap().to_str().unwrap(); | ||
|
||
let full_path = format!("{}/{}", folder_name, flac_name); | ||
|
||
if full_path.len() > REDACTED_MAX_LENGTH { | ||
return Ok(true); | ||
} | ||
} | ||
|
||
Ok(false) | ||
} |