diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-03-20 13:42:03 +1100 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-03-20 13:42:03 +1100 |
| commit | 51dfb5b3e30caf823c2355ff957c01864f35f9f6 (patch) | |
| tree | 1f0e41397259c6e206aba136ad5070b9de30e1b1 /src/database | |
| parent | 170c23b832eed6dad2b118e50164464cc93e5c4c (diff) | |
| parent | a05d93a1e26181237a76da5ce398c6b08497d591 (diff) | |
| download | tangara-fw-51dfb5b3e30caf823c2355ff957c01864f35f9f6.tar.gz | |
Merge branch 'main' into themes
Diffstat (limited to 'src/database')
| -rw-r--r-- | src/database/database.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/database/database.cpp b/src/database/database.cpp index ec11455b..ca92cf6b 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -229,13 +229,17 @@ auto Database::sizeOnDiskBytes() -> size_t { } auto Database::put(const std::string& key, const std::string& val) -> void { - db_->Put(leveldb::WriteOptions{}, kKeyCustom + key, val); + if (val.empty()) { + db_->Delete(leveldb::WriteOptions{}, kKeyCustom + key); + } else { + db_->Put(leveldb::WriteOptions{}, kKeyCustom + key, val); + } } auto Database::get(const std::string& key) -> std::optional<std::string> { std::string val; auto res = db_->Get(leveldb::ReadOptions{}, kKeyCustom + key, &val); - if (!res.ok()) { + if (!res.ok() || val.empty()) { return {}; } return val; |
