mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
database: Fix issue deserializing part indices
This commit is contained in:
parent
eed133e73d
commit
2928bc92f6
1 changed files with 13 additions and 9 deletions
|
|
@ -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::<Result<Vec<usize>>>()?;
|
||||
.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,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue