summaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-01-20 02:14:01 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2021-01-20 02:14:01 -0500
commitdda203376d472daf288f4721644ad14ee11c3a84 (patch)
tree13ba6655f9067ba50bb9de3b4fa57bd440fe4422 /discord
parenta010aa11a559ba22c94dd3426fd1f313ee0ac667 (diff)
downloadabaddon-portaudio-dda203376d472daf288f4721644ad14ee11c3a84.tar.gz
abaddon-portaudio-dda203376d472daf288f4721644ad14ee11c3a84.zip
clear database on open, don't throw on failed fs::remove
Diffstat (limited to 'discord')
-rw-r--r--discord/store.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/discord/store.cpp b/discord/store.cpp
index 2957f47..76652b5 100644
--- a/discord/store.cpp
+++ b/discord/store.cpp
@@ -18,6 +18,10 @@ Store::Store(bool mem_store) {
return;
}
+ sqlite3_db_config(m_db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
+ sqlite3_exec(m_db, "VACUUM", nullptr, nullptr, nullptr);
+ sqlite3_db_config(m_db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
+
m_db_err = sqlite3_exec(m_db, "PRAGMA journal_mode = WAL", nullptr, nullptr, nullptr);
if (m_db_err != SQLITE_OK) {
fprintf(stderr, "enabling write-ahead-log failed: %s\n", sqlite3_errstr(m_db_err));
@@ -43,8 +47,10 @@ Store::~Store() {
return;
}
- if (m_db_path != ":memory:")
- std::filesystem::remove(m_db_path);
+ if (m_db_path != ":memory:") {
+ std::error_code ec;
+ std::filesystem::remove(m_db_path, ec);
+ }
}
bool Store::IsValid() const {