Allow for excluding directories from Memories endpoint
This commit is contained in:
15
src/state.rs
15
src/state.rs
@@ -9,6 +9,7 @@ pub struct AppState {
|
||||
pub thumbnail_path: String,
|
||||
pub video_path: String,
|
||||
pub gif_path: String,
|
||||
pub excluded_dirs: Vec<String>,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
@@ -18,6 +19,7 @@ impl AppState {
|
||||
thumbnail_path: String,
|
||||
video_path: String,
|
||||
gif_path: String,
|
||||
excluded_dirs: Vec<String>,
|
||||
) -> Self {
|
||||
let playlist_generator = PlaylistGenerator::new();
|
||||
let video_playlist_manager =
|
||||
@@ -30,8 +32,19 @@ impl AppState {
|
||||
thumbnail_path,
|
||||
video_path,
|
||||
gif_path,
|
||||
excluded_dirs,
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse excluded directories from environment variable
|
||||
fn parse_excluded_dirs() -> Vec<String> {
|
||||
env::var("EXCLUDED_DIRS")
|
||||
.unwrap_or_default()
|
||||
.split(',')
|
||||
.filter(|dir| !dir.trim().is_empty())
|
||||
.map(|dir| dir.trim().to_string())
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for AppState {
|
||||
@@ -42,6 +55,7 @@ impl Default for AppState {
|
||||
env::var("THUMBNAILS").expect("THUMBNAILS was not set in the env"),
|
||||
env::var("VIDEO_PATH").expect("VIDEO_PATH was not set in the env"),
|
||||
env::var("GIFS_DIRECTORY").expect("GIFS_DIRECTORY was not set in the env"),
|
||||
Self::parse_excluded_dirs(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -67,6 +81,7 @@ impl AppState {
|
||||
thumbnail_path.to_string_lossy().to_string(),
|
||||
video_path.to_string_lossy().to_string(),
|
||||
gif_path.to_string_lossy().to_string(),
|
||||
Vec::new(), // No excluded directories for test state
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user