diff options
author | Greg Soltis <gsoltis@google.com> | 2018-01-30 14:36:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-30 14:36:22 -0800 |
commit | 3cbdbf2652202a3473271ed298ff50e5797cce68 (patch) | |
tree | 3b24b8feff76b3f7551bd17ffd8f1caa38c552ad /Firestore/Source/Local/FSTLevelDB.mm | |
parent | 6474a82fd6e0e10b2cf97c4dc531e837ec97792b (diff) |
Schema migrations for LevelDB (#728)
* Implement schema versions
* Style fixes
* newlines, copyrights, assumptions
* Fix nullability
* Raw ptr -> shared_ptr
* kVersionTableGlobal -> kVersionGlobalTable
* Drop utils, move into static methods
* Drop extra include
* Add a few more comments
* Move version constant into migrations file
* formatting?
* Fix comment
Diffstat (limited to 'Firestore/Source/Local/FSTLevelDB.mm')
-rw-r--r-- | Firestore/Source/Local/FSTLevelDB.mm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Firestore/Source/Local/FSTLevelDB.mm b/Firestore/Source/Local/FSTLevelDB.mm index 83b932c..d163ed5 100644 --- a/Firestore/Source/Local/FSTLevelDB.mm +++ b/Firestore/Source/Local/FSTLevelDB.mm @@ -20,6 +20,7 @@ #import "FIRFirestoreErrors.h" #import "Firestore/Source/Core/FSTDatabaseInfo.h" +#import "Firestore/Source/Local/FSTLevelDBMigrations.h" #import "Firestore/Source/Local/FSTLevelDBMutationQueue.h" #import "Firestore/Source/Local/FSTLevelDBQueryCache.h" #import "Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.h" @@ -36,6 +37,7 @@ static NSString *const kReservedPathComponent = @"firestore"; using leveldb::DB; using leveldb::Options; +using leveldb::ReadOptions; using leveldb::Status; using leveldb::WriteOptions; @@ -50,6 +52,15 @@ using leveldb::WriteOptions; @implementation FSTLevelDB +/** + * For now this is paranoid, but perhaps disable that in production builds. + */ ++ (const ReadOptions)standardReadOptions { + ReadOptions options; + options.verify_checksums = true; + return options; +} + - (instancetype)initWithDirectory:(NSString *)directory serializer:(FSTLocalSerializer *)serializer { if (self = [super init]) { @@ -115,8 +126,8 @@ using leveldb::WriteOptions; if (!database) { return NO; } - _ptr.reset(database); + [FSTLevelDBMigrations runMigrationsOnDB:_ptr]; return YES; } |