From 61cb8affd74935f5f58849bb3aa0d4a2557338a0 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Thu, 30 Oct 2025 15:49:27 -0400 Subject: [PATCH 1/7] tsk-224: Save file_type to CoverArt --- src/callers/coverart.rs | 1 + src/repo/coverart.rs | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/callers/coverart.rs b/src/callers/coverart.rs index 553b254..5554670 100644 --- a/src/callers/coverart.rs +++ b/src/callers/coverart.rs @@ -77,6 +77,7 @@ pub mod endpoint { &directory, &filename, ); coverart.title = song.album.clone(); + coverart.file_type = icarus_meta::detection::coverart::file_type_from_data(&data).unwrap().file_type; coverart.data = data; match coverart.save_to_filesystem() { diff --git a/src/repo/coverart.rs b/src/repo/coverart.rs index 8ed25a2..d9166f2 100644 --- a/src/repo/coverart.rs +++ b/src/repo/coverart.rs @@ -7,12 +7,13 @@ pub async fn create( ) -> Result { let result = sqlx::query( r#" - INSERT INTO "coverart" (title, directory, filename, song_id) VALUES($1, $2, $3, $4) RETURNING id; + INSERT INTO "coverart" (title, directory, filename, file_type, song_id) VALUES($1, $2, $3, $4, $5) RETURNING id; "#, ) .bind(&coverart.title) .bind(&coverart.directory) .bind(&coverart.filename) + .bind(&coverart.file_type) .bind(song_id) .fetch_one(pool) .await @@ -38,7 +39,7 @@ pub async fn get_coverart( ) -> Result { let result = sqlx::query( r#" - SELECT id, title, directory, filename, song_id FROM "coverart" WHERE id = $1; + SELECT id, title, directory, filename, file_type, song_id FROM "coverart" WHERE id = $1; "#, ) .bind(id) @@ -66,6 +67,10 @@ pub async fn get_coverart( .try_get("filename") .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), + file_type: row + .try_get("file_typ") + .map_err(|_e| sqlx::Error::RowNotFound) + .unwrap(), song_id: row .try_get("song_id") .map_err(|_e| sqlx::Error::RowNotFound) @@ -82,7 +87,7 @@ pub async fn get_coverart_with_song_id( ) -> Result { let result = sqlx::query( r#" - SELECT id, title, directory, filename, song_id FROM "coverart" WHERE song_id = $1; + SELECT id, title, directory, filename, file_type, song_id FROM "coverart" WHERE song_id = $1; "#, ) .bind(song_id) @@ -110,6 +115,10 @@ pub async fn get_coverart_with_song_id( .try_get("filename") .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), + file_type: row + .try_get("file_typ") + .map_err(|_e| sqlx::Error::RowNotFound) + .unwrap(), data: Vec::new(), song_id: row .try_get("song_id") @@ -129,7 +138,7 @@ pub async fn delete_coverart( r#" DELETE FROM "coverart" WHERE id = $1 - RETURNING id, title, directory, filename, song_id + RETURNING id, title, directory, filename, file_type, song_id "#, ) .bind(id) @@ -157,6 +166,10 @@ pub async fn delete_coverart( .try_get("filename") .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), + file_type: row + .try_get("file_typ") + .map_err(|_e| sqlx::Error::RowNotFound) + .unwrap(), song_id: row .try_get("song_id") .map_err(|_e| sqlx::Error::RowNotFound) -- 2.47.3 From e225ff9f82ffa2577b9497c8e0477f51210aa8f0 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Thu, 30 Oct 2025 15:59:06 -0400 Subject: [PATCH 2/7] tsk-224: Updated migrations --- migrations/20250420185217_init_migration.sql | 2 +- test_migrations/20250725213944_init.sql | 1 + test_migrations/20250725214735_song_queue_processed.sql | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/migrations/20250420185217_init_migration.sql b/migrations/20250420185217_init_migration.sql index 0083b57..1b67b0e 100644 --- a/migrations/20250420185217_init_migration.sql +++ b/migrations/20250420185217_init_migration.sql @@ -58,6 +58,6 @@ CREATE TABLE IF NOT EXISTS "coverart" ( title TEXT NOT NULL, directory TEXT NOT NULL, filename TEXT NOT NULL, + file_type TEXT NOT NULL, song_id UUID NOT NULL - -- TODO: Add type later ); diff --git a/test_migrations/20250725213944_init.sql b/test_migrations/20250725213944_init.sql index d186f00..c4c922f 100644 --- a/test_migrations/20250725213944_init.sql +++ b/test_migrations/20250725213944_init.sql @@ -56,5 +56,6 @@ CREATE TABLE IF NOT EXISTS "coverart" ( title TEXT NOT NULL, directory TEXT NOT NULL, filename TEXT NOT NULL, + file_type TEXT NOT NULL, song_id UUID NOT NULL ); diff --git a/test_migrations/20250725214735_song_queue_processed.sql b/test_migrations/20250725214735_song_queue_processed.sql index 016f0a4..17d6b61 100644 --- a/test_migrations/20250725214735_song_queue_processed.sql +++ b/test_migrations/20250725214735_song_queue_processed.sql @@ -1,6 +1,6 @@ -- Add migration script here INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id) VALUES('44cf7940-34ff-489f-9124-d0ec90a55af9', 'Hypocrite Like The Rest', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 1, 1, 9, 1, 139, 'flac', '2020-01-01 13:00:00-05', 'track01.flac', 'tests/I', '47491f9b-725a-4ba4-b9a5-711e1be46670'); -INSERT INTO "coverart" (id, title, directory, filename, song_id) VALUES('996122cd-5ae9-4013-9934-60768d3006ed', 'I', 'tests/I', 'Coverart-1.jpg', '44cf7940-34ff-489f-9124-d0ec90a55af9'); +INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) VALUES('996122cd-5ae9-4013-9934-60768d3006ed', 'I', 'tests/I', 'Coverart-1.jpg', 'jpg', '44cf7940-34ff-489f-9124-d0ec90a55af9'); INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id) VALUES('94cf7940-34ff-489f-9124-d0ec90a55af4', 'It''s Too Late', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 2, 1, 9, 1, 116, 'flac', '2020-01-01 13:01:00-05', 'track02.flac', 'tests/I', '47491f9b-725a-4ba4-b9a5-711e1be46670'); -INSERT INTO "coverart" (id, title, directory, filename, song_id) VALUES('d96122cd-5ae9-4013-9934-60768d3006e9', 'I', 'tests/I', 'Coverart-2.jpg', '94cf7940-34ff-489f-9124-d0ec90a55af4'); +INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) VALUES('d96122cd-5ae9-4013-9934-60768d3006e9', 'I', 'tests/I', 'Coverart-2.jpg', 'jpg', '94cf7940-34ff-489f-9124-d0ec90a55af4'); -- 2.47.3 From cbe30c69b98991c7c7ee02d3fc2516b66d23ba73 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Thu, 30 Oct 2025 15:59:23 -0400 Subject: [PATCH 3/7] tsk-224: Code formatting --- src/callers/coverart.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/callers/coverart.rs b/src/callers/coverart.rs index 5554670..118e23f 100644 --- a/src/callers/coverart.rs +++ b/src/callers/coverart.rs @@ -77,7 +77,10 @@ pub mod endpoint { &directory, &filename, ); coverart.title = song.album.clone(); - coverart.file_type = icarus_meta::detection::coverart::file_type_from_data(&data).unwrap().file_type; + coverart.file_type = + icarus_meta::detection::coverart::file_type_from_data(&data) + .unwrap() + .file_type; coverart.data = data; match coverart.save_to_filesystem() { -- 2.47.3 From b116115bb3f081d75da6a781d44c21d017677ce4 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Thu, 30 Oct 2025 16:08:17 -0400 Subject: [PATCH 4/7] tsk-224: Fix test --- test_migrations/20250725214735_song_queue_processed.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_migrations/20250725214735_song_queue_processed.sql b/test_migrations/20250725214735_song_queue_processed.sql index 17d6b61..96f179b 100644 --- a/test_migrations/20250725214735_song_queue_processed.sql +++ b/test_migrations/20250725214735_song_queue_processed.sql @@ -1,6 +1,6 @@ -- Add migration script here INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id) VALUES('44cf7940-34ff-489f-9124-d0ec90a55af9', 'Hypocrite Like The Rest', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 1, 1, 9, 1, 139, 'flac', '2020-01-01 13:00:00-05', 'track01.flac', 'tests/I', '47491f9b-725a-4ba4-b9a5-711e1be46670'); -INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) VALUES('996122cd-5ae9-4013-9934-60768d3006ed', 'I', 'tests/I', 'Coverart-1.jpg', 'jpg', '44cf7940-34ff-489f-9124-d0ec90a55af9'); +INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) VALUES('996122cd-5ae9-4013-9934-60768d3006ed', 'I', 'tests/I', 'Coverart-1.jpg', 'jpeg', '44cf7940-34ff-489f-9124-d0ec90a55af9'); INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id) VALUES('94cf7940-34ff-489f-9124-d0ec90a55af4', 'It''s Too Late', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 2, 1, 9, 1, 116, 'flac', '2020-01-01 13:01:00-05', 'track02.flac', 'tests/I', '47491f9b-725a-4ba4-b9a5-711e1be46670'); -INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) VALUES('d96122cd-5ae9-4013-9934-60768d3006e9', 'I', 'tests/I', 'Coverart-2.jpg', 'jpg', '94cf7940-34ff-489f-9124-d0ec90a55af4'); +INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) VALUES('d96122cd-5ae9-4013-9934-60768d3006e9', 'I', 'tests/I', 'Coverart-2.jpg', 'jpeg', '94cf7940-34ff-489f-9124-d0ec90a55af4'); -- 2.47.3 From 543ecd6d1adf4507b1f2a8d9cacf5bb8ecb03654 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Thu, 30 Oct 2025 16:13:17 -0400 Subject: [PATCH 5/7] tsk-224: Test fix --- src/repo/coverart.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/repo/coverart.rs b/src/repo/coverart.rs index d9166f2..4b13f11 100644 --- a/src/repo/coverart.rs +++ b/src/repo/coverart.rs @@ -68,7 +68,7 @@ pub async fn get_coverart( .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), file_type: row - .try_get("file_typ") + .try_get("file_type") .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), song_id: row @@ -116,7 +116,7 @@ pub async fn get_coverart_with_song_id( .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), file_type: row - .try_get("file_typ") + .try_get("file_type") .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), data: Vec::new(), @@ -167,7 +167,7 @@ pub async fn delete_coverart( .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), file_type: row - .try_get("file_typ") + .try_get("file_type") .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), song_id: row -- 2.47.3 From 811c2e553e4bf231e1097c370fd5fa68f30a4134 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Thu, 30 Oct 2025 16:13:30 -0400 Subject: [PATCH 6/7] tsk-224: Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1508538..c47abf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -964,7 +964,7 @@ dependencies = [ [[package]] name = "icarus" -version = "0.3.13" +version = "0.3.14" dependencies = [ "axum", "axum-extra", diff --git a/Cargo.toml b/Cargo.toml index 24d91a2..53c8c25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icarus" -version = "0.3.13" +version = "0.3.14" edition = "2024" rust-version = "1.90" -- 2.47.3 From af80c6ced803db62d1759bf77efc35d22bb98ad7 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Thu, 30 Oct 2025 16:18:26 -0400 Subject: [PATCH 7/7] tsk-224: Warning fix --- src/repo/coverart.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/repo/coverart.rs b/src/repo/coverart.rs index 4b13f11..bc6dfd7 100644 --- a/src/repo/coverart.rs +++ b/src/repo/coverart.rs @@ -124,7 +124,6 @@ pub async fn get_coverart_with_song_id( .try_get("song_id") .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), - ..Default::default() }), Err(_) => Err(sqlx::Error::RowNotFound), } @@ -175,7 +174,6 @@ pub async fn delete_coverart( .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(), data: Vec::new(), - ..Default::default() }), Err(_err) => Err(sqlx::Error::RowNotFound), } -- 2.47.3