Skip to content

Commit

Permalink
Expose method to repair the DB
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpablo committed Dec 5, 2023
1 parent 315e45d commit a685be6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Code/RocksDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,10 @@ typedef void (^RestoreBlock)(NSError * __autoreleasing *);
- (nullable id)withBulkLoad:(id (NS_NOESCAPE ^)(void))actionBlock
error:(NSError * __autoreleasing *)error;

#pragma mark - Repair

+ (BOOL)repairDB:(NSString *)dbPath options:(RocksDBOptions *)options error:(NSError **)error;

@end

NS_ASSUME_NONNULL_END
15 changes: 15 additions & 0 deletions Code/RocksDB.mm
Original file line number Diff line number Diff line change
Expand Up @@ -804,4 +804,19 @@ - (nullable id)withBulkLoad:(id (NS_NOESCAPE ^)(void))actionBlock
return result;
}

#pragma mark - Repair

+ (BOOL)repairDB:(NSString *)dbPath options:(RocksDBOptions *)options error:(NSError **)error {
rocksdb::Status s = rocksdb::RepairDB(dbPath.UTF8String, options.options);

if (!s.ok()) {
if (error != NULL) {
*error = [RocksDBError errorWithRocksStatus:s];
}
return NO;
}

return YES;
}

@end

0 comments on commit a685be6

Please sign in to comment.