[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>xcode15
parent
933b06d5dd
commit
1fb636ffd2
|
@ -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