full transition to lmdbal, DOESNT WORK, DONT TAKE!
This commit is contained in:
parent
23ec80ccba
commit
9d688e8596
18 changed files with 497 additions and 1752 deletions
|
@ -41,18 +41,12 @@ void Core::UrlStorage::close() {
|
|||
}
|
||||
|
||||
void Core::UrlStorage::writeInfo(const QString& key, const Core::UrlStorage::UrlInfo& info, bool overwrite) {
|
||||
LMDBAL::TransactionID txn = base.beginTransaction();
|
||||
|
||||
try {
|
||||
writeInfo(key, info, txn, overwrite);
|
||||
base.commitTransaction(txn);
|
||||
} catch (...) {
|
||||
base.abortTransaction(txn);
|
||||
throw;
|
||||
}
|
||||
LMDBAL::WriteTransaction txn = base.beginTransaction();
|
||||
writeInfo(key, info, txn, overwrite);
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
void Core::UrlStorage::writeInfo(const QString& key, const Core::UrlStorage::UrlInfo& info, MDB_txn* txn, bool overwrite) {
|
||||
void Core::UrlStorage::writeInfo(const QString& key, const Core::UrlStorage::UrlInfo& info, const LMDBAL::WriteTransaction& txn, bool overwrite) {
|
||||
if (overwrite)
|
||||
urlToInfo->forceRecord(key, info, txn);
|
||||
else
|
||||
|
@ -95,15 +89,11 @@ Core::UrlStorage::UrlInfo Core::UrlStorage::addToInfo(
|
|||
const QString& path
|
||||
) {
|
||||
UrlInfo info;
|
||||
LMDBAL::TransactionID txn = base.beginTransaction();
|
||||
LMDBAL::WriteTransaction txn = base.beginTransaction();
|
||||
|
||||
try {
|
||||
urlToInfo->getRecord(url, info, txn);
|
||||
} catch (const LMDBAL::NotFound& e) {
|
||||
} catch (...) {
|
||||
base.abortTransaction(txn);
|
||||
throw;
|
||||
}
|
||||
} catch (const LMDBAL::NotFound& e) {}
|
||||
|
||||
bool pathChange = false;
|
||||
bool listChange = false;
|
||||
|
@ -118,15 +108,8 @@ Core::UrlStorage::UrlInfo Core::UrlStorage::addToInfo(
|
|||
listChange = info.addMessage(account, jid, id);
|
||||
|
||||
if (pathChange || listChange) {
|
||||
try {
|
||||
writeInfo(url, info, txn, true);
|
||||
base.commitTransaction(txn);
|
||||
} catch (...) {
|
||||
base.abortTransaction(txn);
|
||||
throw;
|
||||
}
|
||||
} else {
|
||||
base.abortTransaction(txn);
|
||||
writeInfo(url, info, txn, true);
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
return info;
|
||||
|
@ -134,70 +117,51 @@ Core::UrlStorage::UrlInfo Core::UrlStorage::addToInfo(
|
|||
|
||||
std::list<Shared::MessageInfo> Core::UrlStorage::setPath(const QString& url, const QString& path) {
|
||||
std::list<Shared::MessageInfo> list;
|
||||
LMDBAL::TransactionID txn = base.beginTransaction();
|
||||
LMDBAL::WriteTransaction txn = base.beginTransaction();
|
||||
UrlInfo info;
|
||||
|
||||
try {
|
||||
urlToInfo->getRecord(url, info, txn);
|
||||
info.getMessages(list);
|
||||
} catch (const LMDBAL::NotFound& e) {
|
||||
} catch (...) {
|
||||
base.abortTransaction(txn);
|
||||
throw;
|
||||
}
|
||||
} catch (const LMDBAL::NotFound& e) {}
|
||||
|
||||
info.setPath(path);
|
||||
try {
|
||||
writeInfo(url, info, txn, true);
|
||||
base.commitTransaction(txn);
|
||||
} catch (...) {
|
||||
base.abortTransaction(txn);
|
||||
throw;
|
||||
}
|
||||
writeInfo(url, info, txn, true);
|
||||
txn.commit();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
std::list<Shared::MessageInfo> Core::UrlStorage::removeFile(const QString& url) {
|
||||
std::list<Shared::MessageInfo> list;
|
||||
LMDBAL::TransactionID txn = base.beginTransaction();
|
||||
LMDBAL::WriteTransaction txn = base.beginTransaction();
|
||||
UrlInfo info;
|
||||
|
||||
try {
|
||||
urlToInfo->getRecord(url, info, txn);
|
||||
urlToInfo->removeRecord(url);
|
||||
info.getMessages(list);
|
||||
|
||||
if (info.hasPath())
|
||||
pathToUrl->removeRecord(info.getPath());
|
||||
urlToInfo->getRecord(url, info, txn);
|
||||
urlToInfo->removeRecord(url, txn);
|
||||
info.getMessages(list);
|
||||
|
||||
base.commitTransaction(txn);
|
||||
} catch (...) {
|
||||
base.abortTransaction(txn);
|
||||
throw;
|
||||
}
|
||||
if (info.hasPath())
|
||||
pathToUrl->removeRecord(info.getPath(), txn);
|
||||
|
||||
txn.commit();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
std::list<Shared::MessageInfo> Core::UrlStorage::deletedFile(const QString& path) {
|
||||
std::list<Shared::MessageInfo> list;
|
||||
LMDBAL::TransactionID txn = base.beginTransaction();
|
||||
LMDBAL::WriteTransaction txn = base.beginTransaction();
|
||||
|
||||
try {
|
||||
QString url = pathToUrl->getRecord(path, txn);
|
||||
pathToUrl->removeRecord(path);
|
||||
|
||||
UrlInfo info = urlToInfo->getRecord(url, txn);
|
||||
info.getMessages(list);
|
||||
info.setPath(QString());
|
||||
urlToInfo->changeRecord(url, info, txn);
|
||||
|
||||
base.commitTransaction(txn);
|
||||
} catch (...) {
|
||||
base.abortTransaction(txn);
|
||||
throw;
|
||||
}
|
||||
QString url = pathToUrl->getRecord(path, txn);
|
||||
pathToUrl->removeRecord(path, txn);
|
||||
|
||||
UrlInfo info = urlToInfo->getRecord(url, txn);
|
||||
info.getMessages(list);
|
||||
info.setPath(QString());
|
||||
urlToInfo->changeRecord(url, info, txn);
|
||||
|
||||
txn.commit();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
|
||||
private:
|
||||
void writeInfo(const QString& key, const UrlInfo& info, bool overwrite = false);
|
||||
void writeInfo(const QString& key, const UrlInfo& info, MDB_txn* txn, bool overwrite = false);
|
||||
void writeInfo(const QString& key, const UrlInfo& info, const LMDBAL::WriteTransaction& txn, bool overwrite = false);
|
||||
UrlInfo addToInfo(const QString& url, const QString& account, const QString& jid, const QString& id, const QString& path = "-s");
|
||||
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue