From 264195d3a250f19b8c74df22f6f1633c5ab1cf0d Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 17 Jul 2025 20:08:12 -0400 Subject: [PATCH] Cleanup warnings --- src/tags.rs | 14 +++++++------- src/video/ffmpeg.rs | 9 +++------ src/video/mod.rs | 10 ++++------ 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/tags.rs b/src/tags.rs index 9c2ea59..7a75061 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -299,7 +299,7 @@ impl TagDao for SqliteTagDao { ) -> anyhow::Result> { // select name, count(*) from tags join tagged_photo ON tags.id = tagged_photo.tag_id GROUP BY tags.name ORDER BY COUNT(*); - trace_db_call(&context, "query", "get_all_tags", |span| { + trace_db_call(context, "query", "get_all_tags", |span| { span.set_attribute(KeyValue::new("path", path.clone().unwrap_or_default())); let path = path.map(|p| p + "%").unwrap_or("%".to_string()); @@ -334,7 +334,7 @@ impl TagDao for SqliteTagDao { context: &opentelemetry::Context, path: &str, ) -> anyhow::Result> { - trace_db_call(&context, "query", "get_tags_for_path", |span| { + trace_db_call(context, "query", "get_tags_for_path", |span| { span.set_attribute(KeyValue::new("path", path.to_string())); debug!("Getting Tags for path: {:?}", path); @@ -348,7 +348,7 @@ impl TagDao for SqliteTagDao { } fn create_tag(&mut self, context: &opentelemetry::Context, name: &str) -> anyhow::Result { - trace_db_call(&context, "insert", "create_tag", |span| { + trace_db_call(context, "insert", "create_tag", |span| { span.set_attribute(KeyValue::new("name", name.to_string())); diesel::insert_into(tags::table) @@ -386,7 +386,7 @@ impl TagDao for SqliteTagDao { tag_name: &str, path: &str, ) -> anyhow::Result> { - trace_db_call(&context, "delete", "remove_tag", |span| { + trace_db_call(context, "delete", "remove_tag", |span| { span.set_attributes(vec![ KeyValue::new("tag_name", tag_name.to_string()), KeyValue::new("path", path.to_string()), @@ -421,7 +421,7 @@ impl TagDao for SqliteTagDao { path: &str, tag_id: i32, ) -> anyhow::Result { - trace_db_call(&context, "insert", "tag_file", |span| { + trace_db_call(context, "insert", "tag_file", |span| { span.set_attributes(vec![ KeyValue::new("path", path.to_string()), KeyValue::new("tag_id", tag_id.to_string()), @@ -464,7 +464,7 @@ impl TagDao for SqliteTagDao { exclude_tag_ids: Vec, context: &opentelemetry::Context, ) -> anyhow::Result> { - trace_db_call(&context, "query", "get_files_with_all_tags", |_| { + trace_db_call(context, "query", "get_files_with_all_tags", |_| { use diesel::dsl::*; let exclude_subquery = tagged_photo::table @@ -501,7 +501,7 @@ impl TagDao for SqliteTagDao { exclude_tag_ids: Vec, context: &opentelemetry::Context, ) -> anyhow::Result> { - trace_db_call(&context, "query", "get_files_with_any_tags", |_| { + trace_db_call(context, "query", "get_files_with_any_tags", |_| { use diesel::dsl::*; // Create the placeholders for the IN clauses let tag_placeholders = std::iter::repeat("?") diff --git a/src/video/ffmpeg.rs b/src/video/ffmpeg.rs index 289b120..d678153 100644 --- a/src/video/ffmpeg.rs +++ b/src/video/ffmpeg.rs @@ -1,9 +1,6 @@ -use futures::future::{Inspect, MapOk}; -use futures::task::SpawnExt; -use futures::{FutureExt, TryFutureExt}; -use log::{debug, error, info, trace, warn}; -use std::future::Future; -use std::io::{Result, Stdout}; +use futures::TryFutureExt; +use log::{debug, error, info, warn}; +use std::io::{Result}; use std::process::{Output, Stdio}; use std::time::Instant; use tokio::process::Command; diff --git a/src/video/mod.rs b/src/video/mod.rs index c7618e3..0d64712 100644 --- a/src/video/mod.rs +++ b/src/video/mod.rs @@ -16,7 +16,7 @@ pub async fn generate_video_gifs() { let start = std::time::Instant::now(); let tracer = global_tracer(); - let span = tracer.start("creating video gifs"); + tracer.start("creating video gifs"); let gif_base_path = &dotenv::var("GIFS_DIRECTORY").unwrap_or(String::from("gifs")); let gif_directory: &Path = Path::new(gif_base_path); @@ -29,7 +29,7 @@ pub async fn generate_video_gifs() { .into_iter() .filter_map(|entry| entry.ok()) .filter(|entry| entry.file_type().is_file()) - .filter(|entry| is_video(entry)) + .filter(is_video) .filter(|entry| { let path = entry.path(); let relative_path = &path.strip_prefix(&files).unwrap(); @@ -43,10 +43,8 @@ pub async fn generate_video_gifs() { let gif_path = Path::new(gif_directory).join(relative_path); let gif_path = gif_path.with_extension("gif"); if let Some(parent_dir) = gif_path.parent() { - fs::create_dir_all(parent_dir).expect(&format!( - "There was an issue creating gif directory {:?}", - gif_path - )); + fs::create_dir_all(parent_dir).unwrap_or_else(|_| panic!("There was an issue creating gif directory {:?}", + gif_path)); } info!("Generating gif for {:?}", path);