fix: resolve clippy warnings (collapsible_if, manual_clamp)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -49,11 +49,11 @@ impl ExifService {
|
|||||||
meta.captured_at = parse_exif_datetime(&field.display_value().to_string());
|
meta.captured_at = parse_exif_datetime(&field.display_value().to_string());
|
||||||
}
|
}
|
||||||
// Fallback to DateTimeDigitized if DateTimeOriginal is missing
|
// Fallback to DateTimeDigitized if DateTimeOriginal is missing
|
||||||
if meta.captured_at.is_none() {
|
if meta.captured_at.is_none()
|
||||||
if let Some(field) = exif.get_field(Tag::DateTimeDigitized, In::PRIMARY) {
|
&& let Some(field) = exif.get_field(Tag::DateTimeDigitized, In::PRIMARY)
|
||||||
|
{
|
||||||
meta.captured_at = parse_exif_datetime(&field.display_value().to_string());
|
meta.captured_at = parse_exif_datetime(&field.display_value().to_string());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// ── GPS coordinates ──
|
// ── GPS coordinates ──
|
||||||
meta.latitude = parse_gps_coord(&exif, Tag::GPSLatitude, Tag::GPSLatitudeRef);
|
meta.latitude = parse_gps_coord(&exif, Tag::GPSLatitude, Tag::GPSLatitudeRef);
|
||||||
@@ -84,15 +84,13 @@ impl ExifService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Orientation ──
|
// ── Orientation ──
|
||||||
if let Some(field) = exif.get_field(Tag::Orientation, In::PRIMARY) {
|
if let Some(field) = exif.get_field(Tag::Orientation, In::PRIMARY)
|
||||||
if let exif::Value::Short(ref v) = field.value {
|
&& let exif::Value::Short(ref v) = field.value
|
||||||
if let Some(&o) = v.first() {
|
&& let Some(&o) = v.first()
|
||||||
if (1..=8).contains(&o) {
|
&& (1..=8).contains(&o)
|
||||||
|
{
|
||||||
meta.orientation = Some(o);
|
meta.orientation = Some(o);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Dimensions ──
|
// ── Dimensions ──
|
||||||
if let Some(field) = exif.get_field(Tag::PixelXDimension, In::PRIMARY) {
|
if let Some(field) = exif.get_field(Tag::PixelXDimension, In::PRIMARY) {
|
||||||
@@ -102,16 +100,16 @@ impl ExifService {
|
|||||||
meta.height = parse_u32_value(&field.value);
|
meta.height = parse_u32_value(&field.value);
|
||||||
}
|
}
|
||||||
// Fallback to ImageWidth/ImageLength if PixelXDimension is missing
|
// Fallback to ImageWidth/ImageLength if PixelXDimension is missing
|
||||||
if meta.width.is_none() {
|
if meta.width.is_none()
|
||||||
if let Some(field) = exif.get_field(Tag::ImageWidth, In::PRIMARY) {
|
&& let Some(field) = exif.get_field(Tag::ImageWidth, In::PRIMARY)
|
||||||
|
{
|
||||||
meta.width = parse_u32_value(&field.value);
|
meta.width = parse_u32_value(&field.value);
|
||||||
}
|
}
|
||||||
}
|
if meta.height.is_none()
|
||||||
if meta.height.is_none() {
|
&& let Some(field) = exif.get_field(Tag::ImageLength, In::PRIMARY)
|
||||||
if let Some(field) = exif.get_field(Tag::ImageLength, In::PRIMARY) {
|
{
|
||||||
meta.height = parse_u32_value(&field.value);
|
meta.height = parse_u32_value(&field.value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Some(meta)
|
Some(meta)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -635,12 +635,12 @@ impl FileHandler {
|
|||||||
use crate::infrastructure::services::exif_service::ExifService;
|
use crate::infrastructure::services::exif_service::ExifService;
|
||||||
match tokio::fs::read(&file_path).await {
|
match tokio::fs::read(&file_path).await {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
if let Some(meta) = ExifService::extract(&data) {
|
if let Some(meta) = ExifService::extract(&data)
|
||||||
if let Err(e) = metadata_repo.upsert(&file_id, &meta).await {
|
&& let Err(e) = metadata_repo.upsert(&file_id, &meta).await
|
||||||
|
{
|
||||||
tracing::warn!("Failed to store EXIF for {}: {}", file_id, e);
|
tracing::warn!("Failed to store EXIF for {}: {}", file_id, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
"Failed to read file for EXIF extraction {}: {}",
|
"Failed to read file for EXIF extraction {}: {}",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ pub async fn list_photos(
|
|||||||
Query(params): Query<PhotosQueryParams>,
|
Query(params): Query<PhotosQueryParams>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
let user_id = &auth_user.id;
|
let user_id = &auth_user.id;
|
||||||
let limit = params.limit.unwrap_or(200).min(500).max(1);
|
let limit = params.limit.unwrap_or(200).clamp(1, 500);
|
||||||
|
|
||||||
let file_read = &state.repositories.file_read_repository;
|
let file_read = &state.repositories.file_read_repository;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user