From 385335b37c573bbb3aad27f9e6252f76abd524ec Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 19 Jun 2022 20:04:30 -0700 Subject: [PATCH] [Core Data Storage] Refine deleted/empty items Remove empty items also with empty URL fields. Signed-off-by: Christopher Snowhill --- Application/AppController.m | 2 +- Playlist/PlaylistController.m | 6 +++--- Playlist/PlaylistLoader.m | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Application/AppController.m b/Application/AppController.m index 026c245d6..44e602565 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -224,7 +224,7 @@ BOOL kAppControllerShuttingDown = NO; int lastStatus = (int)[[NSUserDefaults standardUserDefaults] integerForKey:@"lastPlaybackStatus"]; if(lastStatus != CogStatusStopped) { - NSPredicate *deletedPredicate = [NSPredicate predicateWithFormat:@"deLeted == NO || deLeted == nil"]; + NSPredicate *deletedPredicate = [NSPredicate predicateWithFormat:@"deLeted == NO || deLeted == nil || urlString == nil"]; NSPredicate *currentPredicate = [NSPredicate predicateWithFormat:@"current == YES"]; NSCompoundPredicate *predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[deletedPredicate, currentPredicate]]; diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 170390eb9..39d5687d4 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -1140,7 +1140,7 @@ static void *playlistControllerContext = &playlistControllerContext; } - (NSArray *)filterPlaylistOnAlbum:(NSString *)album { - NSPredicate *deletedPredicate = [NSPredicate predicateWithFormat:@"deLeted == NO || deLeted == nil"]; + NSPredicate *deletedPredicate = [NSPredicate predicateWithFormat:@"deLeted == NO || deLeted == nil || urlString == nil"]; NSPredicate *searchPredicate; if([album length] > 0) @@ -1243,7 +1243,7 @@ static void *playlistControllerContext = &playlistControllerContext; } - (void)readQueueFromDataStore { - NSPredicate *deletedPredicate = [NSPredicate predicateWithFormat:@"deLeted == NO || deLeted == nil"]; + NSPredicate *deletedPredicate = [NSPredicate predicateWithFormat:@"deLeted == NO || deLeted == nil || urlString == nil"]; NSPredicate *queuedPredicate = [NSPredicate predicateWithFormat:@"queued == YES"]; NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"queuePosition" ascending:YES]; @@ -1265,7 +1265,7 @@ static void *playlistControllerContext = &playlistControllerContext; } - (void)readShuffleListFromDataStore { - NSPredicate *predicate = [NSPredicate predicateWithFormat:@"deLeted == NO || deLeted == nil"]; + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"deLeted == NO || deLeted == nil || urlString == nil"]; NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"shuffleIndex" ascending:YES]; diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index 5f1bb8c79..f1032fa0b 100644 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -810,7 +810,7 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc NSMutableIndexSet *pruneSet = [[NSMutableIndexSet alloc] init]; NSUInteger index = 0; for(PlaylistEntry *pe in resultsCopy) { - if(pe.deLeted) { + if(pe.deLeted || !pe.url) { [pruneSet addIndex:index]; [moc deleteObject:pe]; }