From d03fb11f4c8958fd621be1588308eea8be0c9792 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Tue, 5 Jul 2022 23:47:05 -0700 Subject: [PATCH] [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 --- .../Preferences/SandboxPathBehaviorController.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Preferences/Preferences/SandboxPathBehaviorController.m b/Preferences/Preferences/SandboxPathBehaviorController.m index 0a9ca69c2..c3f6fd9e5 100644 --- a/Preferences/Preferences/SandboxPathBehaviorController.m +++ b/Preferences/Preferences/SandboxPathBehaviorController.m @@ -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]); } } }