From b4054aa2b79e2cbfcd158a6da06a9272c1f592dc Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Sat, 18 May 2024 16:32:31 -0400 Subject: [PATCH] Ensure track is specified if album is specified --- src/upload.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/upload.rs b/src/upload.rs index 6e0a3a4..ff7d30d 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -239,6 +239,11 @@ pub async fn upload(data: MultipartData) -> Result<(), ServerFnError> { let track = track.unwrap_or(None); let release_date = release_date.unwrap_or(None); + if album_id.is_some() != track.is_some() { + return Err(ServerFnError:: + ::ServerError("Album id and track number must both be present or both be absent".to_string())); + } + // Create the song use crate::models::Song; let song = Song {