Commit 1ac1e072 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Library: Add missing exception handling when deleting empty albums and shows

parent 58f4b5da
......@@ -774,13 +774,25 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma
file.isSafe = YES; // It doesn't exists, it's safe.
if (file.isAlbumTrack) {
MLAlbum *album = file.albumTrack.album;
if (album.tracks.count <= 1)
[[self managedObjectContext] deleteObject:album];
if (album.tracks.count <= 1) {
@try {
[[self managedObjectContext] deleteObject:album];
}
@catch (NSException *exception) {
APLog(@"failed to nuke object because it disappeared in front of us");
}
}
}
if (file.isShowEpisode) {
MLShow *show = file.showEpisode.show;
if (show.episodes.count <= 1)
[[self managedObjectContext] deleteObject:show];
if (show.episodes.count <= 1) {
@try {
[[self managedObjectContext] deleteObject:show];
}
@catch (NSException *exception) {
APLog(@"failed to nuke object because it disappeared in front of us");
}
}
}
#if TARGET_OS_IPHONE
NSString *thumbPath = [[[self thumbnailFolderPath] stringByAppendingPathComponent:[[file.objectID URIRepresentation] path]] stringByAppendingString:@".png"];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment