| 149 | } |
| 150 | |
| 151 | CDBEnv::VerifyResult CDBEnv::Verify(const std::string& strFile, bool (*recoverFunc)(CDBEnv& dbenv, const std::string& strFile)) |
| 152 | { |
| 153 | LOCK(cs_db); |
| 154 | assert(mapFileUseCount.count(strFile) == 0); |
| 155 | |
| 156 | Db db(dbenv, 0); |
| 157 | int result = db.verify(strFile.c_str(), NULL, NULL, 0); |
| 158 | if (result == 0) |
| 159 | return VERIFY_OK; |
| 160 | else if (recoverFunc == NULL) |
| 161 | return RECOVER_FAIL; |
| 162 | |
| 163 | // Try to recover: |
| 164 | bool fRecovered = (*recoverFunc)(*this, strFile); |
| 165 | return (fRecovered ? RECOVER_OK : RECOVER_FAIL); |
| 166 | } |
| 167 | |
| 168 | bool CDBEnv::Salvage(const std::string& strFile, bool fAggressive, std::vector<CDBEnv::KeyValPair>& vResult) |
| 169 | { |