MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / repair

Method repair

src/database/cppsqlite3.cpp:1659–1703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1657
1658
1659bool CppSQLite3DB::repair(const CString& strDBFileName, const CString& strRetFileName)
1660{
1661 try
1662 {
1663 CString strTempFileName = Utils::WizPathResolve::tempPath() + WizIntToStr(WizGetTickCount()) + ".tmp";
1664 //
1665 CppSQLite3DB dbSrc;
1666 dbSrc.open(strDBFileName);
1667 //
1668 if (!dbSrc.dump(strTempFileName))
1669 {
1670 throw CppSQLite3Exception(-1, "Failed to dump database!");
1671 }
1672 //
1673 dbSrc.close();
1674 //
1675 if (WizPathFileExists(strRetFileName))
1676 {
1677 WizDeleteFile(strRetFileName);
1678 }
1679 //
1680 CppSQLite3DB dbDest;
1681 dbDest.open(strRetFileName);
1682 //
1683 if (!dbDest.read(strTempFileName))
1684 {
1685 throw CppSQLite3Exception(-1, "Failed to rebuild database form index!");
1686 }
1687 //
1688 dbDest.close();
1689 //
1690#ifdef Q_OS_WIN32
1691 _flushall();
1692#endif
1693 //
1694 return true;
1695 }
1696 catch (CppSQLite3Exception& e)
1697 {
1698 TOLOG(e.errorMessage());
1699 return false;
1700 }
1701 //
1702 return false;
1703}
1704
1705

Callers

nothing calls this directly

Calls 10

WizIntToStrFunction · 0.85
WizGetTickCountFunction · 0.85
CppSQLite3ExceptionClass · 0.85
WizPathFileExistsFunction · 0.85
WizDeleteFileFunction · 0.85
TOLOGFunction · 0.85
dumpMethod · 0.80
openMethod · 0.45
closeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected