feat: implement media metadata management with EXIF and TrackInfo support

This commit is contained in:
2025-11-14 07:41:54 +01:00
parent ea95c2255f
commit 55cf4db2de
18 changed files with 343 additions and 195 deletions

View File

@@ -31,8 +31,8 @@ impl MediaRepository for PostgresMediaRepository {
async fn create(&self, media: &Media) -> CoreResult<()> {
sqlx::query!(
r#"
INSERT INTO media (id, owner_id, storage_path, original_filename, mime_type, hash, created_at, width, height, thumbnail_path)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
INSERT INTO media (id, owner_id, storage_path, original_filename, mime_type, hash, created_at, thumbnail_path)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
"#,
media.id,
media.owner_id,
@@ -41,8 +41,6 @@ impl MediaRepository for PostgresMediaRepository {
media.mime_type,
media.hash,
media.created_at,
media.width,
media.height,
media.thumbnail_path
)
.execute(&self.pool)
@@ -114,33 +112,6 @@ impl MediaRepository for PostgresMediaRepository {
Ok(media_list)
}
async fn update_exif_data(
&self,
id: Uuid,
width: Option<i32>,
height: Option<i32>,
location: Option<String>,
date_taken: Option<chrono::DateTime<chrono::Utc>>,
) -> CoreResult<()> {
sqlx::query!(
r#"
UPDATE media
SET width = $2, height = $3, extracted_location = $4, date_taken = $5
WHERE id = $1 AND date_taken IS NULL
"#,
id,
width,
height,
location,
date_taken
)
.execute(&self.pool)
.await
.map_err(|e| CoreError::Database(e.to_string()))?;
Ok(())
}
async fn update_thumbnail_path(&self, id: Uuid, thumbnail_path: String) -> CoreResult<()> {
sqlx::query!(
r#"