2016-10-10 3 views
1

우리는 Realm 버전 2.0.2의 Objective-C 버전을 사용하고 있습니다. 데이터베이스가 현재 암호화되어 있고 필드에 있습니다.기존의 영역 데이터베이스에서 암호화를 제거 할 수있는 방법이 있습니까?

영역 시작시 간헐적 인 충돌이 발생했으며 "경로에서 영역을 열 수 없습니다 ... 영역 파일 암호화가 실패했습니다"라는 오류 메시지가 표시됩니다. 우리는 Realm에서 사용 가능한 최신 버전이며 솔루션을 찾을 수 없었습니다.

데이터베이스를 암호화 할 필요가 없으므로 암호화를 제거하는 것이 좋습니다. 이것이 옵션입니까, 그렇다면 기존 암호화 된 데이터베이스를 어떻게 마이 그 레이션합니까?

답변

1

당신은 암호화되지 않은 사본을 작성하는 nil 암호화 키를 writeCopyToURL:encryptionKey:error:를 사용하고 원본 파일을 통해 것을 이동 :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    RLMRealmConfiguration *confg = [[RLMRealmConfiguration alloc] init]; 
    config.encryptionKey = ...; 
    NSURL *tempUrl = [NSURL URLWithString:[NSTemporaryDirectory() stringByAppendingPathComponent:"temp.realm"]]; 

    // Open the Realm within an autoreleasepool so that it's closed before we try 
    // to overwrite the original file 
    @autoreleasepool { 
     RLMRealm *realm = [RLMRealm realmWithConfiguration:config error:nil]; 
     [realm writeCopyToURL:tempUrl encryptionKey:nil error:nil]; 
    } 

    [[NSFileManager defaultManager] moveItemAtURL:tempUrl toURL:config.fileUrl error:nil]; 

    // ... other didFinishLaunchingWithOptions things ... 

    return YES; 
} 
+0

감사합니다 - 이것은 우리가 필요한처럼 들린다. 우리가이 길을 택하기로 결정하면 얼마나 잘 작동하는지 응답 해 드리겠습니다. – user3768135

+0

어떻게 신속하게이 작업을 수행 할 수 있습니까? –

관련 문제