X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fdbsetup.cpp;h=e6065f7b4d2c133017e880cceabfb055b8efdd93;hb=30c26abc85a6331fecdcb6b03813710bfbc63d3f;hp=1b037f7dac0b0cc372eef39e1da646cf2d09d036;hpb=221236a4d3aac4144529d418ce368db5c98facb0;p=fms.git diff --git a/src/dbsetup.cpp b/src/dbsetup.cpp index 1b037f7..e6065f7 100644 --- a/src/dbsetup.cpp +++ b/src/dbsetup.cpp @@ -602,7 +602,24 @@ const bool VerifyDB() } else { - return false; + // try to reindex and vacuum database in case of index corruption + st=db->Prepare("REINDEX;"); + st.Step(); + st=db->Prepare("VACUUM;"); + st.Step(); + + // check integrity again + st=db->Prepare("PRAGMA integrity_check;"); + st.Step(); + st.ResultText(0,res); + if(res=="ok") + { + return true; + } + else + { + return false; + } } } else @@ -610,3 +627,20 @@ const bool VerifyDB() return false; } } + +const std::string TestDBIntegrity() +{ + std::string result=""; + + SQLite3DB::DB *db=SQLite3DB::DB::Instance(); + SQLite3DB::Statement st=db->Prepare("PRAGMA integrity_check;"); + st.Step(); + while(st.RowReturned()) + { + std::string text=""; + st.ResultText(0,text); + result+=text; + st.Step(); + } + return result; +}