Commit 787fca87 authored by Felix Paul Kühne's avatar Felix Paul Kühne

library: correctly branch to prevent frequent exceptions

parent 2cbabeb6
......@@ -934,27 +934,31 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
file.isSafe = YES; // It doesn't exist, it's safe.
if (file.isAlbumTrack) {
MLAlbum *album = file.albumTrack.album;
if (album.tracks.count <= 1) {
@try {
[moc deleteObject:album];
}
@catch (NSException *exception) {
APLog(@"failed to nuke object because it disappeared in front of us");
}
} else
[album removeTrack:file.albumTrack];
if (album != nil) {
if (album.tracks.count <= 1) {
@try {
[moc deleteObject:album];
}
@catch (NSException *exception) {
APLog(@"failed to nuke object because it disappeared in front of us");
}
} else
[album removeTrack:file.albumTrack];
}
}
if (file.isShowEpisode) {
MLShow *show = file.showEpisode.show;
if (show.episodes.count <= 1) {
@try {
[moc deleteObject:show];
}
@catch (NSException *exception) {
APLog(@"failed to nuke object because it disappeared in front of us");
}
} else
[show removeEpisode:file.showEpisode];
if (show != nil) {
if (show.episodes.count <= 1) {
@try {
[moc deleteObject:show];
}
@catch (NSException *exception) {
APLog(@"failed to nuke object because it disappeared in front of us");
}
} else
[show removeEpisode:file.showEpisode];
}
}
#if TARGET_OS_IPHONE
NSString *thumbPath = [file thumbnailPath];
......
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