Commit 55103bb5 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Remove remnants in existing albums and shows if the users opens the upgraded for the first time

parent 65c1134e
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
// Pref key // Pref key
static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime"; static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseFormat 2.2"; static NSString *kUpdatedToTheGreatSharkHuntDatabaseFormat = @"upgradedToDatabaseFormat 2.3";
#if HAVE_BLOCK #if HAVE_BLOCK
@interface MLMediaLibrary () @interface MLMediaLibrary ()
...@@ -59,7 +59,7 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma ...@@ -59,7 +59,7 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma
@implementation MLMediaLibrary @implementation MLMediaLibrary
+ (void)initialize + (void)initialize
{ {
[[NSUserDefaults standardUserDefaults] registerDefaults:@{kUpdatedToTheMojoWireDatabaseFormat : [NSNumber numberWithBool:NO]}]; [[NSUserDefaults standardUserDefaults] registerDefaults:@{kUpdatedToTheGreatSharkHuntDatabaseFormat : [NSNumber numberWithBool:NO]}];
} }
+ (id)sharedMediaLibrary + (id)sharedMediaLibrary
...@@ -664,7 +664,7 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma ...@@ -664,7 +664,7 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma
- (BOOL)libraryNeedsUpgrade - (BOOL)libraryNeedsUpgrade
{ {
if (![[[NSUserDefaults standardUserDefaults] objectForKey:kUpdatedToTheMojoWireDatabaseFormat] boolValue]) if (![[[NSUserDefaults standardUserDefaults] objectForKey:kUpdatedToTheGreatSharkHuntDatabaseFormat] boolValue])
return YES; return YES;
return NO; return NO;
} }
...@@ -703,6 +703,8 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma ...@@ -703,6 +703,8 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma
BOOL exists = [fileManager fileExistsAtPath:[fileURL path]]; BOOL exists = [fileManager fileExistsAtPath:[fileURL path]];
if (exists) if (exists)
emptyAlbumCounter++; emptyAlbumCounter++;
else
[album removeTrack:track];
} }
} }
if (emptyAlbumCounter == 0) if (emptyAlbumCounter == 0)
...@@ -733,6 +735,8 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma ...@@ -733,6 +735,8 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma
BOOL exists = [fileManager fileExistsAtPath:[fileURL path]]; BOOL exists = [fileManager fileExistsAtPath:[fileURL path]];
if (exists) if (exists)
emptyAlbumCounter++; emptyAlbumCounter++;
else
[show removeEpisode:showEpisode];
} }
} }
if (emptyAlbumCounter == 0) if (emptyAlbumCounter == 0)
...@@ -756,7 +760,7 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma ...@@ -756,7 +760,7 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma
} }
[seenFiles release]; [seenFiles release];
[defaults setBool:YES forKey:kUpdatedToTheMojoWireDatabaseFormat]; [defaults setBool:YES forKey:kUpdatedToTheGreatSharkHuntDatabaseFormat];
[defaults synchronize]; [defaults synchronize];
[self libraryDidAppear]; [self libraryDidAppear];
...@@ -790,8 +794,7 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma ...@@ -790,8 +794,7 @@ static NSString *kUpdatedToTheMojoWireDatabaseFormat = @"upgradedToDatabaseForma
@catch (NSException *exception) { @catch (NSException *exception) {
APLog(@"failed to nuke object because it disappeared in front of us"); APLog(@"failed to nuke object because it disappeared in front of us");
} }
} } else
else
[album removeTrack:file.albumTrack]; [album removeTrack:file.albumTrack];
} }
if (file.isShowEpisode) { if (file.isShowEpisode) {
......
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