diff --git a/Playlist/PlaylistController.h b/Playlist/PlaylistController.h index a5e0195aa..a2ce9e19d 100644 --- a/Playlist/PlaylistController.h +++ b/Playlist/PlaylistController.h @@ -143,6 +143,7 @@ typedef NS_ENUM(NSInteger, URLOrigin) { // Play statistics - (void)updatePlayCountForTrack:(PlaylistEntry *_Nonnull)pe; +- (void)firstSawTrack:(PlaylistEntry *_Nonnull)pe; - (void)moveObjectsInArrangedObjectsFromIndexes:(NSIndexSet *_Nullable)indexSet toIndex:(NSUInteger)insertIndex; diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 0a0cf899e..e2dfb5e6a 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -1675,11 +1675,6 @@ static void *playlistControllerContext = &playlistControllerContext; - (void)didInsertURLs:(NSArray *)urls origin:(URLOrigin)origin { if(![urls count]) return; - for(PlaylistEntry *pe in urls) { - [self firstSawTrack:pe]; - } - [self commitPersistentStore]; - NSArray *nsurls = [urls valueForKey:@"url"]; if(![[SandboxBroker sharedSandboxBroker] areAllPathsSafe:nsurls]) { [appController showPathSuggester]; diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index c2e093461..f464eb299 100644 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -735,9 +735,13 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path); __block NSString *entryKey = [outArray objectAtIndex:i]; __block NSDictionary *entryInfo = [outArray objectAtIndex:i + 1]; __block NSMutableIndexSet *weakUpdateIndexes = update_indexes; + PlaylistController *playlistController = self->playlistController; dispatch_sync_reentrant(dispatch_get_main_queue(), ^{ NSArray *entrySet = [uniquePathsEntries objectForKey:entryKey]; if(entrySet) { + if([entrySet count] > 0) { + [playlistController firstSawTrack:entrySet[0]]; + } for(PlaylistEntry *pe in entrySet) { [pe setMetadata:entryInfo]; if(pe.index >= 0 && pe.index < NSNotFound) { @@ -811,6 +815,7 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path); NSDictionary *entryInfo = [NSDictionary dictionaryByMerging:entryProperties with:[AudioMetadataReader metadataForURL:pe.url]]; [pe setMetadata:entryInfo]; + [playlistController firstSawTrack:pe]; }]; [self->playlistController updateTotalTime];