diff --git a/src/handlers/video.rs b/src/handlers/video.rs index 21338b0..c535fac 100644 --- a/src/handlers/video.rs +++ b/src/handlers/video.rs @@ -80,11 +80,10 @@ pub async fn generate_video( return HttpResponse::BadRequest().finish(); }; - let preferred_library = - libraries::resolve_library_param(&app_state, body.library.as_deref()) - .ok() - .flatten() - .unwrap_or_else(|| app_state.primary_library()); + let preferred_library = libraries::resolve_library_param(&app_state, body.library.as_deref()) + .ok() + .flatten() + .unwrap_or_else(|| app_state.primary_library()); // Try the resolved library first, then fall back to any other library // that actually contains the file — handles union-mode requests where @@ -122,7 +121,11 @@ pub async fn generate_video( // already-ingested videos. let hash_from_db: Option = { let mut dao = exif_dao.lock().expect("Unable to lock ExifDao"); - match dao.get_exif_batch(&context, Some(resolved_library_id), &[rel_path.clone()]) { + match dao.get_exif_batch( + &context, + Some(resolved_library_id), + std::slice::from_ref(&rel_path), + ) { Ok(rows) => rows.into_iter().next().and_then(|r| r.content_hash), Err(e) => { warn!( diff --git a/src/hls_stats.rs b/src/hls_stats.rs index 3e7fb03..c587aaf 100644 --- a/src/hls_stats.rs +++ b/src/hls_stats.rs @@ -256,15 +256,14 @@ pub async fn hls_stats_handler( // Synchronous file IO + DB query — run on a blocking pool so the // actix worker thread stays free for other requests. - let stats = match web::block(move || compute_and_publish(&libraries, &exif_dao, &video_dir)) - .await - { - Ok(s) => s, - Err(e) => { - warn!("/hls/stats: blocking task failed: {:?}", e); - Vec::new() - } - }; + let stats = + match web::block(move || compute_and_publish(&libraries, &exif_dao, &video_dir)).await { + Ok(s) => s, + Err(e) => { + warn!("/hls/stats: blocking task failed: {:?}", e); + Vec::new() + } + }; let total: usize = stats.iter().map(|s| s.total).sum(); let with_playlist: usize = stats.iter().map(|s| s.with_playlist).sum(); diff --git a/src/video/legacy_migration.rs b/src/video/legacy_migration.rs index 0db8e25..ed6863c 100644 --- a/src/video/legacy_migration.rs +++ b/src/video/legacy_migration.rs @@ -38,10 +38,7 @@ pub struct RetireStats { impl RetireStats { pub fn total_deleted(&self) -> usize { - self.deleted_playlists - + self.deleted_segments - + self.deleted_sentinels - + self.deleted_tmp + self.deleted_playlists + self.deleted_segments + self.deleted_sentinels + self.deleted_tmp } } diff --git a/src/watcher.rs b/src/watcher.rs index 6f04855..13ac1cd 100644 --- a/src/watcher.rs +++ b/src/watcher.rs @@ -79,9 +79,10 @@ pub fn cleanup_orphaned_playlists( info!(" Cleanup interval: {} seconds", cleanup_interval_secs); info!(" HLS directory: {}", video_path.display()); - let exif_dao: Arc>> = Arc::new(Mutex::new( - Box::new(SqliteExifDao::new()) as Box - )); + let exif_dao: Arc>> = Arc::new(Mutex::new(Box::new( + SqliteExifDao::new(), + ) + as Box)); loop { std::thread::sleep(Duration::from_secs(cleanup_interval_secs)); @@ -163,11 +164,7 @@ pub fn cleanup_orphaned_playlists( for shard_entry in read_root.flatten() { let shard_path = shard_entry.path(); - if !shard_entry - .file_type() - .map(|t| t.is_dir()) - .unwrap_or(false) - { + if !shard_entry.file_type().map(|t| t.is_dir()).unwrap_or(false) { continue; } let shard_name = match shard_path.file_name().and_then(|n| n.to_str()) { @@ -194,16 +191,14 @@ pub fn cleanup_orphaned_playlists( let mut shard_emptied = true; for hash_entry in read_shard.flatten() { let hash_path = hash_entry.path(); - if !hash_entry - .file_type() - .map(|t| t.is_dir()) - .unwrap_or(false) - { + if !hash_entry.file_type().map(|t| t.is_dir()).unwrap_or(false) { shard_emptied = false; continue; } - let Some(hash_name) = - hash_path.file_name().and_then(|n| n.to_str()).map(|n| n.to_owned()) + let Some(hash_name) = hash_path + .file_name() + .and_then(|n| n.to_str()) + .map(|n| n.to_owned()) else { shard_emptied = false; continue; @@ -586,13 +581,9 @@ pub fn watch_files( // quick scans because the cost is non-trivial on big // libraries and the data only meaningfully changes on // full passes. - let video_dir_str = - dotenv::var("VIDEO_PATH").expect("VIDEO_PATH must be set"); - let stats = hls_stats::compute_and_publish( - &libs, - &exif_dao, - Path::new(&video_dir_str), - ); + let video_dir_str = dotenv::var("VIDEO_PATH").expect("VIDEO_PATH must be set"); + let stats = + hls_stats::compute_and_publish(&libs, &exif_dao, Path::new(&video_dir_str)); hls_stats::log_summary(&stats); last_full_scan = now;