| 341 | } |
| 342 | |
| 343 | bool BerkeleyBatch::VerifyDatabaseFile(const fs::path& file_path, std::string& warningStr, std::string& errorStr, BerkeleyEnvironment::recoverFunc_type recoverFunc) |
| 344 | { |
| 345 | std::string walletFile; |
| 346 | BerkeleyEnvironment* env = GetWalletEnv(file_path, walletFile); |
| 347 | fs::path walletDir = env->Directory(); |
| 348 | |
| 349 | if (fs::exists(walletDir / walletFile)) |
| 350 | { |
| 351 | std::string backup_filename; |
| 352 | BerkeleyEnvironment::VerifyResult r = env->Verify(walletFile, recoverFunc, backup_filename); |
| 353 | if (r == BerkeleyEnvironment::VerifyResult::RECOVER_OK) |
| 354 | { |
| 355 | warningStr = strprintf(_("Warning: Wallet file corrupt, data salvaged!" |
| 356 | " Original %s saved as %s in %s; if" |
| 357 | " your balance or transactions are incorrect you should" |
| 358 | " restore from a backup."), |
| 359 | walletFile, backup_filename, walletDir); |
| 360 | } |
| 361 | if (r == BerkeleyEnvironment::VerifyResult::RECOVER_FAIL) |
| 362 | { |
| 363 | errorStr = strprintf(_("%s corrupt, salvage failed"), walletFile); |
| 364 | return false; |
| 365 | } |
| 366 | } |
| 367 | // also return true if files does not exists |
| 368 | return true; |
| 369 | } |
| 370 | |
| 371 | /* End of headers, beginning of key/value data */ |
| 372 | static const char *HEADER_END = "HEADER=END"; |
nothing calls this directly
no test coverage detected