| 231 | } |
| 232 | |
| 233 | BerkeleyEnvironment::VerifyResult BerkeleyEnvironment::Verify(const std::string& strFile, recoverFunc_type recoverFunc, std::string& out_backup_filename) |
| 234 | { |
| 235 | LOCK(cs_db); |
| 236 | assert(mapFileUseCount.count(strFile) == 0); |
| 237 | |
| 238 | Db db(dbenv.get(), 0); |
| 239 | int result = db.verify(strFile.c_str(), nullptr, nullptr, 0); |
| 240 | if (result == 0) |
| 241 | return VerifyResult::VERIFY_OK; |
| 242 | else if (recoverFunc == nullptr) |
| 243 | return VerifyResult::RECOVER_FAIL; |
| 244 | |
| 245 | // Try to recover: |
| 246 | bool fRecovered = (*recoverFunc)(fs::path(strPath) / strFile, out_backup_filename); |
| 247 | return (fRecovered ? VerifyResult::RECOVER_OK : VerifyResult::RECOVER_FAIL); |
| 248 | } |
| 249 | |
| 250 | bool BerkeleyBatch::Recover(const fs::path& file_path, void *callbackDataIn, bool (*recoverKVcallback)(void* callbackData, CDataStream ssKey, CDataStream ssValue), std::string& newFilename) |
| 251 | { |