Commit 0c6bfc6e authored by Romain Goyet's avatar Romain Goyet

Adding a public method to be able to update the database

parent 3406134a
......@@ -16,6 +16,7 @@
+ (id)sharedMediaLibrary;
- (void)addFilePaths:(NSArray *)filepaths;
- (void)updateDatabase; // Removes missing files
// May be internal
- (NSFetchRequest *)fetchRequestForEntity:(NSString *)entity;
......
......@@ -35,7 +35,6 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
@interface MLMediaLibrary () <MLMovieInfoGrabberDelegate, MLTVShowEpisodesInfoGrabberDelegate, MLTVShowInfoGrabberDelegate>
#endif
- (NSManagedObjectContext *)managedObjectContext;
- (void)startUpdateDB;
- (NSString *)databaseFolderPath;
@end
......@@ -46,7 +45,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
if (!sharedMediaLibrary) {
sharedMediaLibrary = [[[self class] alloc] init];
NSLog(@"Initializing db in %@", [sharedMediaLibrary databaseFolderPath]);
[sharedMediaLibrary startUpdateDB];
[sharedMediaLibrary updateDatabase];
}
return sharedMediaLibrary;
}
......@@ -583,7 +582,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
}
#endif
- (void)startUpdateDB
- (void)updateDatabase
{
// Remove no more present files
NSFetchRequest *request = [self fetchRequestForEntity:@"File"];
......@@ -642,7 +641,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
[grabber fetchUpdatesSinceServerTime:lastServerTime];
#endif
/* Update every hour - FIXME: Preferences key */
[self performSelector:@selector(startUpdateDB) withObject:nil afterDelay:60 * 60];
[self performSelector:@selector(updateDatabase) withObject:nil afterDelay:60 * 60];
}
- (void)libraryDidDisappear
......
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