database: Fix issue deserializing part indices

This commit is contained in:
Elias Projahn 2021-02-08 17:23:53 +01:00
parent eed133e73d
commit 2928bc92f6

View file

@ -280,19 +280,23 @@ impl Database {
let mut tracks = Vec::new(); let mut tracks = Vec::new();
for track_row in track_rows { for track_row in track_rows {
let mut part_indices = Vec::new();
let work_parts = track_row let work_parts = track_row
.work_parts .work_parts
.split(',') .split(',');
.map(|part_index| {
str::parse(part_index) for part_index in work_parts {
.or(Err(Error::Other( if !part_index.is_empty() {
format!("Failed to parse part index from '{}'.", track_row.work_parts, let index = str::parse(part_index)
)))) .or(Err(Error::Other(format!("Failed to parse part index from '{}'.", track_row.work_parts))))?;
})
.collect::<Result<Vec<usize>>>()?; part_indices.push(index);
}
}
let track = Track { let track = Track {
work_parts, work_parts: part_indices,
path: track_row.path, path: track_row.path,
}; };