| 1657 | |
| 1658 | |
| 1659 | bool 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 |
nothing calls this directly
no test coverage detected