Skip to content

Commit a685be6

Browse files
committed
Expose method to repair the DB
1 parent 315e45d commit a685be6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Code/RocksDB.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ typedef void (^RestoreBlock)(NSError * __autoreleasing *);
590590
- (nullable id)withBulkLoad:(id (NS_NOESCAPE ^)(void))actionBlock
591591
error:(NSError * __autoreleasing *)error;
592592

593+
#pragma mark - Repair
594+
595+
+ (BOOL)repairDB:(NSString *)dbPath options:(RocksDBOptions *)options error:(NSError **)error;
596+
593597
@end
594598

595599
NS_ASSUME_NONNULL_END

Code/RocksDB.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,4 +804,19 @@ - (nullable id)withBulkLoad:(id (NS_NOESCAPE ^)(void))actionBlock
804804
return result;
805805
}
806806

807+
#pragma mark - Repair
808+
809+
+ (BOOL)repairDB:(NSString *)dbPath options:(RocksDBOptions *)options error:(NSError **)error {
810+
rocksdb::Status s = rocksdb::RepairDB(dbPath.UTF8String, options.options);
811+
812+
if (!s.ok()) {
813+
if (error != NULL) {
814+
*error = [RocksDBError errorWithRocksStatus:s];
815+
}
816+
return NO;
817+
}
818+
819+
return YES;
820+
}
821+
807822
@end

0 commit comments

Comments
 (0)