From d5ca0379431ebd9b72fbb6805cb711d9968baa91 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Thu, 27 Feb 2025 00:56:58 -0800 Subject: [PATCH] Bug Fix: Playlist Loader now correctly sorts items Playlist Loader was sorting only the non-container tracks, and not the final track list. Move the sort operation to the end of the processing. Signed-off-by: Christopher Snowhill --- Playlist/PlaylistLoader.m | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index 6d7466f82..87b115925 100644 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -418,21 +418,13 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc DLog(@"Expanded urls: %@", expandedURLs); - NSArray *sortedURLs; - if(sort == YES) { - sortedURLs = [expandedURLs sortedArrayUsingSelector:@selector(finderCompare:)]; - // sortedURLs = [expandedURLs sortedArrayUsingSelector:@selector(compareTrackNumbers:)]; - } else { - sortedURLs = expandedURLs; - } - [self beginProgressJob:NSLocalizedString(@"ProgressSubActionLoaderFilteringContainerFiles", @"") percentOfTotal:20.0]; - progressstep = [sortedURLs count] ? 100.0 / (double)([sortedURLs count]) : 0; + progressstep = [expandedURLs count] ? 100.0 / (double)([expandedURLs count]) : 0; id containerTask = [mainTask startChildWithOperation:@"Process paths for containers"]; - for(url in sortedURLs) { + for(url in expandedURLs) { // Container vs non-container url id pathTask = nil; @try { @@ -637,15 +629,22 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc return @[]; } + NSArray *sortedURLs; + if(sort == YES) { + sortedURLs = [validURLs sortedArrayUsingSelector:@selector(finderCompare:)]; + } else { + sortedURLs = validURLs; + } + [self beginProgressJob:NSLocalizedString(@"ProgressSubActionLoaderAddingEntries", @"") percentOfTotal:20.0]; progressstep = 100.0 / (double)(count); - __block id addTask = [mainTask startChildWithOperation:@"Add entries to playlist" description:[NSString stringWithFormat:@"Adding %lu entries to the playlist", [validURLs count]]]; + __block id addTask = [mainTask startChildWithOperation:@"Add entries to playlist" description:[NSString stringWithFormat:@"Adding %lu entries to the playlist", [sortedURLs count]]]; NSInteger i = 0; __block NSMutableArray *entries = [NSMutableArray arrayWithCapacity:count]; - for(NSURL *url in validURLs) { + for(NSURL *url in sortedURLs) { __block PlaylistEntry *pe; dispatch_sync_reentrant(dispatch_get_main_queue(), ^{