Commit 1381492c authored by Tobias's avatar Tobias Committed by Felix Paul Kühne
Browse files

migrate library to the shared group container

parent 3df6aa14
...@@ -118,6 +118,7 @@ ...@@ -118,6 +118,7 @@
}; };
NSError *error = nil; NSError *error = nil;
[self pathMigrationToGroupsIfNeeded:&error];
if ([self migrationNeeded:&error]){ if ([self migrationNeeded:&error]){
_isRunningMigration = YES; _isRunningMigration = YES;
...@@ -144,6 +145,26 @@ ...@@ -144,6 +145,26 @@
return YES; return YES;
} }
- (void)pathMigrationToGroupsIfNeeded:(NSError **)migrationError
{
MLMediaLibrary *mediaLibrary = [MLMediaLibrary sharedMediaLibrary];
NSURL *groupURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group.org.videolan.vlc-ios"];
NSString *oldBasePath = [mediaLibrary libraryBasePath];
NSString *oldPersistentStorePath = [oldBasePath stringByAppendingPathComponent: @"MediaLibrary.sqlite"];
NSError *error = nil;
if (![[NSFileManager defaultManager] fileExistsAtPath:oldPersistentStorePath]) {
mediaLibrary.libraryBasePath = groupURL.path;
} else if (![mediaLibrary migrateLibraryToBasePath:groupURL.path error:&error]) {
NSLog(@"Failed to migrate Library to new location with error: %@", error);
}
if (migrationError && error) {
*migrationError = error;
}
}
- (BOOL)migrationNeeded:(NSError **) migrationCheckError { - (BOOL)migrationNeeded:(NSError **) migrationCheckError {
BOOL migrationNeeded = NO; BOOL migrationNeeded = NO;
......
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