Fix recursive search at the root, cleanup video generation return

This commit is contained in:
Cameron
2024-12-06 09:47:21 -05:00
parent 8bc9c5585e
commit 787d1fd5d0
2 changed files with 20 additions and 6 deletions

View File

@@ -70,7 +70,17 @@ pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
.map(|tagged_files| {
tagged_files
.into_iter()
.filter(|f| f.starts_with(&format!("{}/", search_path).to_string()))
.filter(|f| {
// When searching at the root, everything matches recursively
if search_path.trim() == "" { return true; }
f.starts_with(
&format!(
"{}/",
search_path.strip_suffix('/').unwrap_or_else(|| search_path)
),
)
})
.collect::<Vec<String>>()
})
.inspect(|files| debug!("Found {:?} files", files.len()))

View File

@@ -156,12 +156,16 @@ impl Handler<ScanDirectoryMessage> for VideoPlaylistManager {
.await
.expect("Failed to send generate playlist message")
{
Ok(_) => {}
Ok(_) => {
debug!(
"Successfully generated playlist for file: '{}'",
path_as_str
);
}
Err(e) => {
warn!("Failed to generate playlist for path '{:?}'. {:?}", path, e);
}
}
// .expect("Failed to generate video playlist");
}
info!(
@@ -180,7 +184,7 @@ pub struct ScanDirectoryMessage {
}
#[derive(Message)]
#[rtype(result = "Result<String>")]
#[rtype(result = "Result<()>")]
struct GeneratePlaylistMessage {
video_path: PathBuf,
playlist_path: String,
@@ -203,7 +207,7 @@ impl Actor for PlaylistGenerator {
}
impl Handler<GeneratePlaylistMessage> for PlaylistGenerator {
type Result = ResponseFuture<Result<String>>;
type Result = ResponseFuture<Result<()>>;
fn handle(&mut self, msg: GeneratePlaylistMessage, _ctx: &mut Self::Context) -> Self::Result {
let video_file = msg.video_path.to_str().unwrap().to_owned();
@@ -266,7 +270,7 @@ impl Handler<GeneratePlaylistMessage> for PlaylistGenerator {
ffmpeg_result
});
Ok("meeee".to_string())
Ok(())
})
}
}