MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / Backup

Method Backup

src/wallet/db.cpp:754–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

752}
753
754bool BerkeleyDatabase::Backup(const std::string& strDest)
755{
756 if (IsDummy()) {
757 return false;
758 }
759 while (true)
760 {
761 {
762 LOCK(cs_db);
763 if (!env->mapFileUseCount.count(strFile) || env->mapFileUseCount[strFile] == 0)
764 {
765 // Flush log data to the dat file
766 env->CloseDb(strFile);
767 env->CheckpointLSN(strFile);
768 env->mapFileUseCount.erase(strFile);
769
770 // Copy wallet file
771 fs::path pathSrc = env->Directory() / strFile;
772 fs::path pathDest(strDest);
773 if (fs::is_directory(pathDest))
774 pathDest /= strFile;
775
776 try {
777 if (fs::equivalent(pathSrc, pathDest)) {
778 LogPrintf("cannot backup to wallet source file %s\n", pathDest.string());
779 return false;
780 }
781
782 fs::copy_file(pathSrc, pathDest, fs::copy_option::overwrite_if_exists);
783 LogPrintf("copied %s to %s\n", strFile, pathDest.string());
784 return true;
785 } catch (const fs::filesystem_error& e) {
786 LogPrintf("error copying %s to %s - %s\n", strFile, pathDest.string(), e.what());
787 return false;
788 }
789 }
790 }
791 MilliSleep(100);
792 }
793}
794
795void BerkeleyDatabase::Flush(bool shutdown)
796{

Callers 1

BackupWalletMethod · 0.80

Calls 7

MilliSleepFunction · 0.85
CloseDbMethod · 0.80
CheckpointLSNMethod · 0.80
DirectoryMethod · 0.80
whatMethod · 0.80
countMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected