mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +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)
|
if(USE_BUNDLED_LMDBXX)
|
||||||
hunter_add_package(lmdbxx)
|
FetchContent_Declare(
|
||||||
find_package(lmdbxx CONFIG REQUIRED)
|
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()
|
else()
|
||||||
if(NOT LMDBXX_INCLUDE_DIR)
|
if(NOT LMDBXX_INCLUDE_DIR)
|
||||||
find_path(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)
|
- CMake 3.15 or greater. (Lower version may work, but may break boost linking)
|
||||||
- [mtxclient](https://github.com/Nheko-Reborn/mtxclient)
|
- [mtxclient](https://github.com/Nheko-Reborn/mtxclient)
|
||||||
- [LMDB](https://symas.com/lightning-memory-mapped-database/)
|
- [LMDB](https://symas.com/lightning-memory-mapped-database/)
|
||||||
|
- [lmdb++](https://github.com/hoytech/lmdbxx)
|
||||||
- [cmark](https://github.com/commonmark/cmark) 0.29 or greater.
|
- [cmark](https://github.com/commonmark/cmark) 0.29 or greater.
|
||||||
- Boost 1.70 or greater.
|
- Boost 1.70 or greater.
|
||||||
- [libolm](https://gitlab.matrix.org/matrix-org/olm)
|
- [libolm](https://gitlab.matrix.org/matrix-org/olm)
|
||||||
|
|
|
@ -258,9 +258,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"dest": ".deps/lmdbxx",
|
"dest": ".deps/lmdbxx",
|
||||||
"sha256": "93721132bbf5045d38ad62de2997655e9984c48ea5c9886746d42128f4b26fbd",
|
"sha256": "5e12eb3aefe9050068af7df2c663edabc977ef34c9e7ba7b9d2c43e0ad47d8df",
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"url": "https://github.com/bendiken/lmdbxx/archive/0b43ca87d8cfabba392dfe884eb1edb83874de02.tar.gz"
|
"url": "https://github.com/hoytech/lmdbxx/archive/1.0.0.tar.gz"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
805
src/Cache.cpp
805
src/Cache.cpp
File diff suppressed because it is too large
Load diff
|
@ -102,9 +102,9 @@ public:
|
||||||
std::size_t len = 30);
|
std::size_t len = 30);
|
||||||
|
|
||||||
void saveState(const mtx::responses::Sync &res);
|
void saveState(const mtx::responses::Sync &res);
|
||||||
bool isInitialized() const;
|
bool isInitialized();
|
||||||
|
|
||||||
std::string nextBatchToken() const;
|
std::string nextBatchToken();
|
||||||
|
|
||||||
void deleteData();
|
void deleteData();
|
||||||
|
|
||||||
|
@ -149,8 +149,8 @@ public:
|
||||||
using UserReceipts = std::multimap<uint64_t, std::string, std::greater<uint64_t>>;
|
using UserReceipts = std::multimap<uint64_t, std::string, std::greater<uint64_t>>;
|
||||||
UserReceipts readReceipts(const QString &event_id, const QString &room_id);
|
UserReceipts readReceipts(const QString &event_id, const QString &room_id);
|
||||||
|
|
||||||
QByteArray image(const QString &url) const;
|
QByteArray image(const QString &url);
|
||||||
QByteArray image(lmdb::txn &txn, const std::string &url) const;
|
QByteArray image(lmdb::txn &txn, const std::string &url);
|
||||||
void saveImage(const std::string &url, const std::string &data);
|
void saveImage(const std::string &url, const std::string &data);
|
||||||
void saveImage(const QString &url, const QByteArray &data);
|
void saveImage(const QString &url, const QByteArray &data);
|
||||||
|
|
||||||
|
@ -330,8 +330,8 @@ private:
|
||||||
// void removeLeftRoom(lmdb::txn &txn, const std::string &room_id);
|
// void removeLeftRoom(lmdb::txn &txn, const std::string &room_id);
|
||||||
template<class T>
|
template<class T>
|
||||||
void saveStateEvents(lmdb::txn &txn,
|
void saveStateEvents(lmdb::txn &txn,
|
||||||
const lmdb::dbi &statesdb,
|
lmdb::dbi &statesdb,
|
||||||
const lmdb::dbi &membersdb,
|
lmdb::dbi &membersdb,
|
||||||
const std::string &room_id,
|
const std::string &room_id,
|
||||||
const std::vector<T> &events)
|
const std::vector<T> &events)
|
||||||
{
|
{
|
||||||
|
@ -341,8 +341,8 @@ private:
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void saveStateEvent(lmdb::txn &txn,
|
void saveStateEvent(lmdb::txn &txn,
|
||||||
const lmdb::dbi &statesdb,
|
lmdb::dbi &statesdb,
|
||||||
const lmdb::dbi &membersdb,
|
lmdb::dbi &membersdb,
|
||||||
const std::string &room_id,
|
const std::string &room_id,
|
||||||
const T &event)
|
const T &event)
|
||||||
{
|
{
|
||||||
|
@ -363,17 +363,11 @@ private:
|
||||||
// Lightweight representation of a member.
|
// Lightweight representation of a member.
|
||||||
MemberInfo tmp{display_name, e->content.avatar_url};
|
MemberInfo tmp{display_name, e->content.avatar_url};
|
||||||
|
|
||||||
lmdb::dbi_put(txn,
|
membersdb.put(txn, e->state_key, json(tmp).dump());
|
||||||
membersdb,
|
|
||||||
lmdb::val(e->state_key),
|
|
||||||
lmdb::val(json(tmp).dump()));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
lmdb::dbi_del(
|
membersdb.del(txn, e->state_key, "");
|
||||||
txn, membersdb, lmdb::val(e->state_key), lmdb::val(""));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,12 +381,9 @@ private:
|
||||||
if (!isStateEvent(event))
|
if (!isStateEvent(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::visit(
|
std::visit([&txn, &statesdb](
|
||||||
[&txn, &statesdb](auto e) {
|
auto e) { statesdb.put(txn, to_string(e.type), json(e).dump()); },
|
||||||
lmdb::dbi_put(
|
event);
|
||||||
txn, statesdb, lmdb::val(to_string(e.type)), lmdb::val(json(e).dump()));
|
|
||||||
},
|
|
||||||
event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
Loading…
Reference in a new issue