mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57: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();
|
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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue