2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 09:05:14 +00:00

Create only temporary keys for CDN.

This commit is contained in:
John Preston
2019-12-28 13:52:29 +03:00
parent f3d5f0c9de
commit a980fba3aa
5 changed files with 71 additions and 30 deletions

View File

@@ -108,7 +108,7 @@ AuthKeyPtr SessionData::getPersistentKey() const {
return _owner ? _owner->getPersistentKey() : nullptr;
}
CreatingKeyType SessionData::acquireKeyCreation(TemporaryKeyType type) {
CreatingKeyType SessionData::acquireKeyCreation(DcType type) {
QMutexLocker lock(&_ownerMutex);
return _owner ? _owner->acquireKeyCreation(type) : CreatingKeyType::None;
}
@@ -124,6 +124,14 @@ bool SessionData::releaseKeyCreationOnDone(
: false;
}
bool SessionData::releaseCdnKeyCreationOnDone(
const AuthKeyPtr &temporaryKey) {
QMutexLocker lock(&_ownerMutex);
return _owner
? _owner->releaseCdnKeyCreationOnDone(temporaryKey)
: false;
}
void SessionData::releaseKeyCreationOnFail() {
QMutexLocker lock(&_ownerMutex);
if (_owner) {
@@ -441,7 +449,7 @@ void Session::sendPrepared(
}
}
CreatingKeyType Session::acquireKeyCreation(TemporaryKeyType type) {
CreatingKeyType Session::acquireKeyCreation(DcType type) {
Expects(_myKeyCreation == CreatingKeyType::None);
_myKeyCreation = _dc->acquireKeyCreation(type);
@@ -454,6 +462,21 @@ bool Session::releaseKeyCreationOnDone(
Expects(_myKeyCreation != CreatingKeyType::None);
Expects(persistentKeyUsedForBind != nullptr);
return releaseGenericKeyCreationOnDone(
temporaryKey,
persistentKeyUsedForBind);
}
bool Session::releaseCdnKeyCreationOnDone(
const AuthKeyPtr &temporaryKey) {
Expects(_myKeyCreation == CreatingKeyType::TemporaryRegular);
return releaseGenericKeyCreationOnDone(temporaryKey, nullptr);
}
bool Session::releaseGenericKeyCreationOnDone(
const AuthKeyPtr &temporaryKey,
const AuthKeyPtr &persistentKeyUsedForBind) {
const auto wasKeyCreation = std::exchange(
_myKeyCreation,
CreatingKeyType::None);