Skip to content

Commit

Permalink
Improve logging for missing playlist entries
Browse files Browse the repository at this point in the history
  • Loading branch information
probablykasper committed Jan 2, 2025
1 parent 817f2a2 commit 4bf02d6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src-native/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::library_types::{ItemId, Library, Track, TRACK_ID_MAP};
use crate::page::TracksPageOptions;
use crate::playlists::get_tracklist_item_ids;
use alphanumeric_sort::compare_str;
use anyhow::Result;
use anyhow::{Context, Result};
use std::cmp::Ordering;
use std::time::Instant;

Expand Down Expand Up @@ -97,15 +97,19 @@ pub fn sort(options: TracksPageOptions, library: &Library) -> Result<Vec<ItemId>
let id_map = TRACK_ID_MAP.read().unwrap();
let tracks = library.get_tracks();

let mut items: Vec<_> = get_tracklist_item_ids(library, &options.playlist_id)?
let items: Result<Vec<SortItem>> = get_tracklist_item_ids(library, &options.playlist_id)?
.into_iter()
.map(|id| SortItem {
item_id: id,
track: tracks
.get(&id_map[id as usize])
.expect("Track ID non-existant"),
.enumerate()
.map(|(i, id)| {
Ok(SortItem {
item_id: id,
track: tracks
.get(&id_map[id as usize])
.context(format!("Track {i} non-existant (item ID {id})"))?,
})
})
.collect();
let mut items = items?;
let item_count = items.len();

if options.sort_key == "index" {
Expand Down

0 comments on commit 4bf02d6

Please sign in to comment.