|
|
@ -903,46 +903,6 @@ void ThreadFlushWalletDB(const string& strFile) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool BackupWallet(const CWallet& wallet, const string& strDest) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!wallet.fFileBacked) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
while (true) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LOCK(bitdb.cs_db); |
|
|
|
|
|
|
|
if (!bitdb.mapFileUseCount.count(wallet.strWalletFile) || bitdb.mapFileUseCount[wallet.strWalletFile] == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Flush log data to the dat file
|
|
|
|
|
|
|
|
bitdb.CloseDb(wallet.strWalletFile); |
|
|
|
|
|
|
|
bitdb.CheckpointLSN(wallet.strWalletFile); |
|
|
|
|
|
|
|
bitdb.mapFileUseCount.erase(wallet.strWalletFile); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Copy wallet file
|
|
|
|
|
|
|
|
boost::filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile; |
|
|
|
|
|
|
|
boost::filesystem::path pathDest(strDest); |
|
|
|
|
|
|
|
if (boost::filesystem::is_directory(pathDest)) |
|
|
|
|
|
|
|
pathDest /= wallet.strWalletFile; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
#if BOOST_VERSION >= 104000 |
|
|
|
|
|
|
|
boost::filesystem::copy_file(pathSrc, pathDest, boost::filesystem::copy_option::overwrite_if_exists); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
boost::filesystem::copy_file(pathSrc, pathDest); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
LogPrintf("copied %s to %s\n", wallet.strWalletFile, pathDest.string()); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} catch (const boost::filesystem::filesystem_error& e) { |
|
|
|
|
|
|
|
LogPrintf("error copying %s to %s - %s\n", wallet.strWalletFile, pathDest.string(), e.what()); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
MilliSleep(100); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Try to (very carefully!) recover wallet file if there is a problem.
|
|
|
|
// Try to (very carefully!) recover wallet file if there is a problem.
|
|
|
|
//
|
|
|
|
//
|
|
|
|