| 595 | } |
| 596 | |
| 597 | void Account::writeMap() { |
| 598 | Expects(_localKey != nullptr); |
| 599 | |
| 600 | _writeMapTimer.cancel(); |
| 601 | if (!_mapChanged) { |
| 602 | return; |
| 603 | } |
| 604 | _mapChanged = false; |
| 605 | |
| 606 | if (!QDir().exists(_basePath)) { |
| 607 | QDir().mkpath(_basePath); |
| 608 | } |
| 609 | |
| 610 | FileWriteDescriptor map(u"map"_q, _basePath); |
| 611 | map.writeData(QByteArray()); |
| 612 | map.writeData(QByteArray()); |
| 613 | |
| 614 | uint32 mapSize = 0; |
| 615 | const auto self = [&] { |
| 616 | if (!_owner->sessionExists()) { |
| 617 | DEBUG_LOG(("AuthSelf Warning: Session does not exist.")); |
| 618 | return QByteArray(); |
| 619 | } |
| 620 | const auto self = _owner->session().user(); |
| 621 | if (self->phone().isEmpty()) { |
| 622 | DEBUG_LOG(("AuthSelf Error: Phone is empty.")); |
| 623 | return QByteArray(); |
| 624 | } |
| 625 | auto result = QByteArray(); |
| 626 | result.reserve(Serialize::peerSize(self) |
| 627 | + Serialize::stringSize(self->about())); |
| 628 | { |
| 629 | QBuffer buffer(&result); |
| 630 | buffer.open(QIODevice::WriteOnly); |
| 631 | QDataStream stream(&buffer); |
| 632 | Serialize::writePeer(stream, self); |
| 633 | stream << self->about(); |
| 634 | } |
| 635 | return result; |
| 636 | }(); |
| 637 | if (!self.isEmpty()) mapSize += sizeof(quint32) + Serialize::bytearraySize(self); |
| 638 | if (!_draftsMap.empty()) mapSize += sizeof(quint32) * 2 + _draftsMap.size() * sizeof(quint64) * 2; |
| 639 | if (!_draftCursorsMap.empty()) mapSize += sizeof(quint32) * 2 + _draftCursorsMap.size() * sizeof(quint64) * 2; |
| 640 | if (_prefsKey) mapSize += sizeof(quint32) + sizeof(quint64); |
| 641 | if (_locationsKey) mapSize += sizeof(quint32) + sizeof(quint64); |
| 642 | if (_trustedPeersKey) mapSize += sizeof(quint32) + sizeof(quint64); |
| 643 | if (_recentStickersKeyOld) mapSize += sizeof(quint32) + sizeof(quint64); |
| 644 | if (_installedStickersKey || _featuredStickersKey || _recentStickersKey || _archivedStickersKey) { |
| 645 | mapSize += sizeof(quint32) + 4 * sizeof(quint64); |
| 646 | } |
| 647 | if (_favedStickersKey) mapSize += sizeof(quint32) + sizeof(quint64); |
| 648 | if (_savedGifsKey) mapSize += sizeof(quint32) + sizeof(quint64); |
| 649 | if (_settingsKey) mapSize += sizeof(quint32) + sizeof(quint64); |
| 650 | if (_recentHashtagsAndBotsKey) mapSize += sizeof(quint32) + sizeof(quint64); |
| 651 | if (_exportSettingsKey) mapSize += sizeof(quint32) + sizeof(quint64); |
| 652 | if (_installedMasksKey || _recentMasksKey || _archivedMasksKey) { |
| 653 | mapSize += sizeof(quint32) + 3 * sizeof(quint64); |
| 654 | } |
nothing calls this directly
no test coverage detected