mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Update to new lmdbxx version
This commit is contained in:
parent
aa04c233bd
commit
1b0abe97f9
5 changed files with 365 additions and 493 deletions
|
@ -417,8 +417,17 @@ set_package_properties(nlohmann_json PROPERTIES
|
|||
)
|
||||
|
||||
if(USE_BUNDLED_LMDBXX)
|
||||
hunter_add_package(lmdbxx)
|
||||
find_package(lmdbxx CONFIG REQUIRED)
|
||||
FetchContent_Declare(
|
||||
lmdbxx
|
||||
GIT_REPOSITORY https://github.com/hoytech/lmdbxx.git
|
||||
GIT_TAG 1.0.0
|
||||
)
|
||||
if(NOT lmdbxx_POPULATED)
|
||||
FetchContent_Populate(lmdbxx)
|
||||
endif()
|
||||
add_library(lmdbxx INTERFACE)
|
||||
target_include_directories(lmdbxx INTERFACE ${lmdbxx_SOURCE_DIR})
|
||||
add_library(lmdbxx::lmdbxx ALIAS lmdbxx)
|
||||
else()
|
||||
if(NOT LMDBXX_INCLUDE_DIR)
|
||||
find_path(LMDBXX_INCLUDE_DIR
|
||||
|
|
|
@ -121,6 +121,7 @@ brew install --cask nheko
|
|||
- CMake 3.15 or greater. (Lower version may work, but may break boost linking)
|
||||
- [mtxclient](https://github.com/Nheko-Reborn/mtxclient)
|
||||
- [LMDB](https://symas.com/lightning-memory-mapped-database/)
|
||||
- [lmdb++](https://github.com/hoytech/lmdbxx)
|
||||
- [cmark](https://github.com/commonmark/cmark) 0.29 or greater.
|
||||
- Boost 1.70 or greater.
|
||||
- [libolm](https://gitlab.matrix.org/matrix-org/olm)
|
||||
|
|
|
@ -258,9 +258,9 @@
|
|||
},
|
||||
{
|
||||
"dest": ".deps/lmdbxx",
|
||||
"sha256": "93721132bbf5045d38ad62de2997655e9984c48ea5c9886746d42128f4b26fbd",
|
||||
"sha256": "5e12eb3aefe9050068af7df2c663edabc977ef34c9e7ba7b9d2c43e0ad47d8df",
|
||||
"type": "archive",
|
||||
"url": "https://github.com/bendiken/lmdbxx/archive/0b43ca87d8cfabba392dfe884eb1edb83874de02.tar.gz"
|
||||
"url": "https://github.com/hoytech/lmdbxx/archive/1.0.0.tar.gz"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
793
src/Cache.cpp
793
src/Cache.cpp
File diff suppressed because it is too large
Load diff
|
@ -102,9 +102,9 @@ public:
|
|||
std::size_t len = 30);
|
||||
|
||||
void saveState(const mtx::responses::Sync &res);
|
||||
bool isInitialized() const;
|
||||
bool isInitialized();
|
||||
|
||||
std::string nextBatchToken() const;
|
||||
std::string nextBatchToken();
|
||||
|
||||
void deleteData();
|
||||
|
||||
|
@ -149,8 +149,8 @@ public:
|
|||
using UserReceipts = std::multimap<uint64_t, std::string, std::greater<uint64_t>>;
|
||||
UserReceipts readReceipts(const QString &event_id, const QString &room_id);
|
||||
|
||||
QByteArray image(const QString &url) const;
|
||||
QByteArray image(lmdb::txn &txn, const std::string &url) const;
|
||||
QByteArray image(const QString &url);
|
||||
QByteArray image(lmdb::txn &txn, const std::string &url);
|
||||
void saveImage(const std::string &url, const std::string &data);
|
||||
void saveImage(const QString &url, const QByteArray &data);
|
||||
|
||||
|
@ -330,8 +330,8 @@ private:
|
|||
// void removeLeftRoom(lmdb::txn &txn, const std::string &room_id);
|
||||
template<class T>
|
||||
void saveStateEvents(lmdb::txn &txn,
|
||||
const lmdb::dbi &statesdb,
|
||||
const lmdb::dbi &membersdb,
|
||||
lmdb::dbi &statesdb,
|
||||
lmdb::dbi &membersdb,
|
||||
const std::string &room_id,
|
||||
const std::vector<T> &events)
|
||||
{
|
||||
|
@ -341,8 +341,8 @@ private:
|
|||
|
||||
template<class T>
|
||||
void saveStateEvent(lmdb::txn &txn,
|
||||
const lmdb::dbi &statesdb,
|
||||
const lmdb::dbi &membersdb,
|
||||
lmdb::dbi &statesdb,
|
||||
lmdb::dbi &membersdb,
|
||||
const std::string &room_id,
|
||||
const T &event)
|
||||
{
|
||||
|
@ -363,17 +363,11 @@ private:
|
|||
// Lightweight representation of a member.
|
||||
MemberInfo tmp{display_name, e->content.avatar_url};
|
||||
|
||||
lmdb::dbi_put(txn,
|
||||
membersdb,
|
||||
lmdb::val(e->state_key),
|
||||
lmdb::val(json(tmp).dump()));
|
||||
|
||||
membersdb.put(txn, e->state_key, json(tmp).dump());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
lmdb::dbi_del(
|
||||
txn, membersdb, lmdb::val(e->state_key), lmdb::val(""));
|
||||
|
||||
membersdb.del(txn, e->state_key, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -387,11 +381,8 @@ private:
|
|||
if (!isStateEvent(event))
|
||||
return;
|
||||
|
||||
std::visit(
|
||||
[&txn, &statesdb](auto e) {
|
||||
lmdb::dbi_put(
|
||||
txn, statesdb, lmdb::val(to_string(e.type)), lmdb::val(json(e).dump()));
|
||||
},
|
||||
std::visit([&txn, &statesdb](
|
||||
auto e) { statesdb.put(txn, to_string(e.type), json(e).dump()); },
|
||||
event);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue