Add GPS summary sorting

Run cargo fmt/clippy
This commit is contained in:
Cameron
2026-01-28 10:52:17 -05:00
parent 7d2a3148bb
commit 1efdd02eda
4 changed files with 138 additions and 72 deletions

View File

@@ -118,7 +118,7 @@ async fn get_image(
// Handle circular thumbnail request
if req.shape == Some(ThumbnailShape::Circle) {
match create_circular_thumbnail(&thumb_path, &thumbs).await {
match create_circular_thumbnail(&thumb_path, thumbs).await {
Ok(circular_path) => {
if let Ok(file) = NamedFile::open(&circular_path) {
span.set_status(Status::Ok);
@@ -173,8 +173,11 @@ fn is_video_file(path: &Path) -> bool {
file_types::is_video_file(path)
}
async fn create_circular_thumbnail(thumb_path: &Path, thumbs_dir: &str) -> Result<PathBuf, Box<dyn std::error::Error>> {
use image::{ImageBuffer, Rgba, GenericImageView};
async fn create_circular_thumbnail(
thumb_path: &Path,
thumbs_dir: &str,
) -> Result<PathBuf, Box<dyn std::error::Error>> {
use image::{GenericImageView, ImageBuffer, Rgba};
// Create circular thumbnails directory
let circular_dir = Path::new(thumbs_dir).join("_circular");
@@ -1040,12 +1043,11 @@ fn cleanup_orphaned_playlists() {
.filter_map(|e| e.ok())
.filter(|e| e.file_type().is_file())
{
if let Some(entry_stem) = entry.path().file_stem() {
if entry_stem == filename && is_video_file(entry.path()) {
if let Some(entry_stem) = entry.path().file_stem()
&& entry_stem == filename && is_video_file(entry.path()) {
video_exists = true;
break;
}
}
}
if !video_exists {
@@ -1056,7 +1058,11 @@ fn cleanup_orphaned_playlists() {
// Delete the playlist file
if let Err(e) = std::fs::remove_file(&playlist_path) {
warn!("Failed to delete playlist {}: {}", playlist_path.display(), e);
warn!(
"Failed to delete playlist {}: {}",
playlist_path.display(),
e
);
error_count += 1;
} else {
deleted_count += 1;
@@ -1071,13 +1077,14 @@ fn cleanup_orphaned_playlists() {
.filter(|e| e.file_type().is_file())
{
let entry_path = entry.path();
if let Some(ext) = entry_path.extension() {
if ext.eq_ignore_ascii_case("ts") {
if let Some(ext) = entry_path.extension()
&& ext.eq_ignore_ascii_case("ts") {
// Check if this .ts file belongs to our playlist
if let Some(ts_stem) = entry_path.file_stem() {
let ts_name = ts_stem.to_string_lossy();
if ts_name.starts_with(&*video_filename) {
if let Err(e) = std::fs::remove_file(entry_path) {
if let Err(e) = std::fs::remove_file(entry_path)
{
debug!(
"Failed to delete segment {}: {}",
entry_path.display(),
@@ -1092,7 +1099,6 @@ fn cleanup_orphaned_playlists() {
}
}
}
}
}
}
}
@@ -1154,7 +1160,12 @@ fn watch_files(playlist_manager: Addr<VideoPlaylistManager>) {
if is_full_scan {
info!("Running full scan (scan #{})", scan_count);
process_new_files(&base_path, Arc::clone(&exif_dao), None, playlist_manager.clone());
process_new_files(
&base_path,
Arc::clone(&exif_dao),
None,
playlist_manager.clone(),
);
last_full_scan = now;
} else {
debug!(
@@ -1165,7 +1176,12 @@ fn watch_files(playlist_manager: Addr<VideoPlaylistManager>) {
let check_since = last_quick_scan
.checked_sub(Duration::from_secs(10))
.unwrap_or(last_quick_scan);
process_new_files(&base_path, Arc::clone(&exif_dao), Some(check_since), playlist_manager.clone());
process_new_files(
&base_path,
Arc::clone(&exif_dao),
Some(check_since),
playlist_manager.clone(),
);
}
last_quick_scan = now;
@@ -1190,13 +1206,12 @@ fn playlist_needs_generation(video_path: &Path, playlist_path: &Path) -> bool {
if let (Ok(video_meta), Ok(playlist_meta)) = (
std::fs::metadata(video_path),
std::fs::metadata(playlist_path),
) {
if let (Ok(video_modified), Ok(playlist_modified)) =
)
&& let (Ok(video_modified), Ok(playlist_modified)) =
(video_meta.modified(), playlist_meta.modified())
{
return video_modified > playlist_modified;
}
}
// If we can't determine, assume it needs generation
true
@@ -1276,7 +1291,7 @@ fn process_new_files(
let needs_thumbnail = !thumb_path.exists();
// Check if EXIF data exists (for supported files)
let needs_exif = if exif::supports_exif(&file_path) {
let needs_exif = if exif::supports_exif(file_path) {
!existing_exif_paths.contains_key(relative_path)
} else {
false
@@ -1349,16 +1364,14 @@ fn process_new_files(
let mut videos_needing_playlists = Vec::new();
for (file_path, _relative_path) in &files {
if is_video_file(&file_path) {
if is_video_file(file_path) {
// Construct expected playlist path
let playlist_filename = format!(
"{}.m3u8",
file_path.file_name().unwrap().to_string_lossy()
);
let playlist_filename =
format!("{}.m3u8", file_path.file_name().unwrap().to_string_lossy());
let playlist_path = Path::new(&video_path_base).join(&playlist_filename);
// Check if playlist needs (re)generation
if playlist_needs_generation(&file_path, &playlist_path) {
if playlist_needs_generation(file_path, &playlist_path) {
videos_needing_playlists.push(file_path.clone());
}
}