[Path Config] Properly prune the database
When cleaning up the path list, actually remove the pruned entries from the Core Data storage, so they don't end up resolving to broken bookmarks in the player, breaking playback on migrated configurations. Signed-off-by: Christopher Snowhill <kode54@gmail.com>lastfm
parent
0e2bfeb671
commit
d03fb11f4c
|
@ -106,9 +106,20 @@
|
|||
}
|
||||
|
||||
- (void)removeStaleEntries {
|
||||
BOOL updated = NO;
|
||||
NSPersistentContainer *pc = [NSClassFromString(@"PlaylistController") sharedPersistentContainer];
|
||||
for(NSDictionary *entry in [[self arrangedObjects] copy]) {
|
||||
if([[entry objectForKey:@"valid"] isEqualToString:NSLocalizedPrefString(@"ValidNo")]) {
|
||||
[self removeObject:entry];
|
||||
[pc.viewContext deleteObject:[entry objectForKey:@"token"]];
|
||||
updated = YES;
|
||||
}
|
||||
}
|
||||
if(updated) {
|
||||
NSError *error;
|
||||
[pc.viewContext save:&error];
|
||||
if(error) {
|
||||
ALog(@"Error saving after removing stale bookmarks: %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue