Move the code updating revision of SQLite database out of destructor to places where it can really change.

sql-rework
Tomasz Golinski 2019-10-04 22:06:59 +02:00
rodzic 5eaf9ec43e
commit d2682e5860
1 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -27,7 +27,6 @@ OCdb::OCdb(std::string db_file) {
}
OCdb::~OCdb() {
request("UPDATE revision SET revision = " + std::to_string(revision) + ';');
sqlite3_close(db);
}
@ -63,6 +62,7 @@ bool OCdb::init(std::string dump_path) {
for (auto& el : j["data_files"].items()) {
init_part(dump_path + el.value().get<std::string>());
}
request("UPDATE revision SET revision = " + std::to_string(revision) + ';');
return 1;
}
@ -91,6 +91,8 @@ bool OCdb::update(Okapi& oc) {
revision = j["revision"];
if (j["more"])
update(oc);
else
request("UPDATE revision SET revision = " + std::to_string(revision) + ';');
return 1;
}