full transition to lmdbal, DOESNT WORK, DONT TAKE!

This commit is contained in:
Blue 2023-11-02 19:55:11 -03:00
parent 23ec80ccba
commit 9d688e8596
Signed by: blue
GPG key ID: 9B203B252A63EE38
18 changed files with 497 additions and 1752 deletions

View file

@ -27,7 +27,7 @@ Core::RosterItem::RosterItem(const QString& pJid, const QString& pAccount, QObje
account(pAccount),
name(),
archiveState(empty),
archive(new Archive(jid)),
archive(new Archive(account, jid)),
syncronizing(false),
requestedCount(0),
requestedBefore(),
@ -38,7 +38,7 @@ Core::RosterItem::RosterItem(const QString& pJid, const QString& pAccount, QObje
toCorrect(),
muc(false)
{
archive->open(account);
archive->open();
if (archive->size() != 0) {
if (archive->isFromTheBeginning())
@ -126,7 +126,8 @@ void Core::RosterItem::nextRequest() {
last = true;
}
}
} catch (const Archive::Empty& e) {
//} catch (const Archive::Empty& e) {
} catch (const LMDBAL::NotFound& e) {
last = true;
}
} else if (archiveState == empty && responseCache.size() == 0) {
@ -168,7 +169,8 @@ void Core::RosterItem::performRequest(int count, const QString& before) {
try {
Shared::Message msg = archive->newest();
emit needHistory("", getId(msg), msg.getTime());
} catch (const Archive::Empty& e) { //this can happen when the only message in archive is not server stored (error, for example)
//} catch (const Archive::Empty& e) {
} catch (const LMDBAL::NotFound& e) { //this can happen when the only message in archive is not server stored (error, for example)
emit needHistory(before, "");
}
}
@ -186,14 +188,14 @@ void Core::RosterItem::performRequest(int count, const QString& before) {
std::list<Shared::Message> arc = archive->getBefore(requestedCount - responseCache.size(), lBefore);
responseCache.insert(responseCache.begin(), arc.begin(), arc.end());
found = true;
} catch (const Archive::NotFound& e) {
requestCache.emplace_back(requestedCount, before);
requestedCount = -1;
emit needHistory(getId(archive->oldest()), "");
} catch (const Archive::Empty& e) {
} catch (const LMDBAL::NotFound& e) {
requestCache.emplace_back(requestedCount, before);
requestedCount = -1;
emit needHistory(getId(archive->oldest()), "");
// } catch (const Archive::Empty& e) {
// requestCache.emplace_back(requestedCount, before);
// requestedCount = -1;
// emit needHistory(getId(archive->oldest()), "");
}
if (found) {
@ -226,10 +228,10 @@ void Core::RosterItem::performRequest(int count, const QString& before) {
try {
std::list<Shared::Message> arc = archive->getBefore(requestedCount - responseCache.size(), before);
responseCache.insert(responseCache.begin(), arc.begin(), arc.end());
} catch (const Archive::NotFound& e) {
qDebug("requesting id hasn't been found in archive, skipping");
} catch (const Archive::Empty& e) {
} catch (const LMDBAL::NotFound& e) {
qDebug("requesting id hasn't been found in archive, skipping");
// } catch (const Archive::Empty& e) {
// qDebug("requesting id hasn't been found in archive, skipping");
}
nextRequest();
break;
@ -311,7 +313,7 @@ bool Core::RosterItem::changeMessage(const QString& id, const QMap<QString, QVar
try {
archive->changeMessage(id, data);
found = true;
} catch (const Archive::NotFound& e) {
} catch (const LMDBAL::NotFound& e) {
qDebug() << "An attempt to change state to the message" << id << "but it couldn't be found";
}
}
@ -387,10 +389,8 @@ void Core::RosterItem::flushMessagesToArchive(bool finished, const QString& firs
std::list<Shared::Message> arc = archive->getBefore(requestedCount - responseCache.size(), before);
responseCache.insert(responseCache.begin(), arc.begin(), arc.end());
found = true;
} catch (const Archive::NotFound& e) {
} catch (const Archive::Empty& e) {
} catch (const LMDBAL::NotFound& e) {
// } catch (const Archive::Empty& e) {
}
if (!found || requestedCount > int(responseCache.size())) {
if (archiveState == complete) {