Ensure track is specified if album is specified

This commit is contained in:
Ethan Girouard 2024-05-18 16:32:31 -04:00
parent 3934a25900
commit b4054aa2b7
Signed by: eta357
GPG Key ID: 7BCDC36DFD11C146

View File

@ -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::<NoCustomError>
::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 {