From 2928bc92f63a357592cc5bd1125ef3ca190d57c3 Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Mon, 8 Feb 2021 17:23:53 +0100 Subject: [PATCH] database: Fix issue deserializing part indices --- database/src/medium.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/database/src/medium.rs b/database/src/medium.rs index 3d7cb3d..d315378 100644 --- a/database/src/medium.rs +++ b/database/src/medium.rs @@ -280,19 +280,23 @@ impl Database { let mut tracks = Vec::new(); for track_row in track_rows { + let mut part_indices = Vec::new(); + let work_parts = track_row .work_parts - .split(',') - .map(|part_index| { - str::parse(part_index) - .or(Err(Error::Other( - format!("Failed to parse part index from '{}'.", track_row.work_parts, - )))) - }) - .collect::>>()?; + .split(','); + + for part_index in work_parts { + if !part_index.is_empty() { + let index = str::parse(part_index) + .or(Err(Error::Other(format!("Failed to parse part index from '{}'.", track_row.work_parts))))?; + + part_indices.push(index); + } + } let track = Track { - work_parts, + work_parts: part_indices, path: track_row.path, };