From df2b020b42ffb840347481ec93911381d7583d1a Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 4 Oct 2024 10:06:14 +0400 Subject: [PATCH] Add debug logs for recent/top peers resetting. --- .../SourceFiles/data/components/recent_peers.cpp | 12 ++++++++++++ Telegram/SourceFiles/data/components/top_peers.cpp | 12 ++++++++++++ Telegram/SourceFiles/storage/storage_account.cpp | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/Telegram/SourceFiles/data/components/recent_peers.cpp b/Telegram/SourceFiles/data/components/recent_peers.cpp index 1c1957873..58fb7dfcc 100644 --- a/Telegram/SourceFiles/data/components/recent_peers.cpp +++ b/Telegram/SourceFiles/data/components/recent_peers.cpp @@ -95,6 +95,7 @@ QByteArray RecentPeers::serialize() const { void RecentPeers::applyLocal(QByteArray serialized) { _list.clear(); if (serialized.isEmpty()) { + DEBUG_LOG(("Suggestions: Bad RecentPeers local, empty.")); return; } auto stream = Serialize::ByteArrayReader(serialized); @@ -102,8 +103,13 @@ void RecentPeers::applyLocal(QByteArray serialized) { auto count = quint32(); stream >> streamAppVersion >> count; if (!stream.ok()) { + DEBUG_LOG(("Suggestions: Bad RecentPeers local, not ok.")); return; } + DEBUG_LOG(("Suggestions: " + "Start RecentPeers read, count: %1, version: %2." + ).arg(count + ).arg(streamAppVersion)); _list.reserve(count); for (auto i = 0; i != int(count); ++i) { const auto peer = Serialize::readPeer( @@ -114,9 +120,15 @@ void RecentPeers::applyLocal(QByteArray serialized) { _list.push_back(peer); } else { _list.clear(); + DEBUG_LOG(("Suggestions: Failed RecentPeers reading %1 / %2." + ).arg(i + 1 + ).arg(count)); + _list.clear(); return; } } + DEBUG_LOG( + ("Suggestions: RecentPeers read OK, count: %1").arg(_list.size())); } } // namespace Data diff --git a/Telegram/SourceFiles/data/components/top_peers.cpp b/Telegram/SourceFiles/data/components/top_peers.cpp index 57974febf..1d6307220 100644 --- a/Telegram/SourceFiles/data/components/top_peers.cpp +++ b/Telegram/SourceFiles/data/components/top_peers.cpp @@ -274,11 +274,13 @@ QByteArray TopPeers::serialize() const { void TopPeers::applyLocal(QByteArray serialized) { if (_lastReceived) { + DEBUG_LOG(("Suggestions: Skipping TopPeers local, got already.")); return; } _list.clear(); _disabled = false; if (serialized.isEmpty()) { + DEBUG_LOG(("Suggestions: Bad TopPeers local, empty.")); return; } auto stream = Serialize::ByteArrayReader(serialized); @@ -287,8 +289,14 @@ void TopPeers::applyLocal(QByteArray serialized) { auto count = quint32(); stream >> streamAppVersion >> disabled >> count; if (!stream.ok()) { + DEBUG_LOG(("Suggestions: Bad TopPeers local, not ok.")); return; } + DEBUG_LOG(("Suggestions: " + "Start TopPeers read, count: %1, version: %2, disabled: %3." + ).arg(count + ).arg(streamAppVersion + ).arg(disabled)); _list.reserve(count); for (auto i = 0; i != int(count); ++i) { auto rating = quint64(); @@ -303,11 +311,15 @@ void TopPeers::applyLocal(QByteArray serialized) { .rating = DeserializeRating(rating), }); } else { + DEBUG_LOG(("Suggestions: " + "Failed TopPeers reading %1 / %2.").arg(i + 1).arg(count)); _list.clear(); return; } } _disabled = (disabled == 1); + DEBUG_LOG( + ("Suggestions: TopPeers read OK, count: %1").arg(_list.size())); } } // namespace Data diff --git a/Telegram/SourceFiles/storage/storage_account.cpp b/Telegram/SourceFiles/storage/storage_account.cpp index bfac71560..074812e13 100644 --- a/Telegram/SourceFiles/storage/storage_account.cpp +++ b/Telegram/SourceFiles/storage/storage_account.cpp @@ -2956,11 +2956,13 @@ void Account::readSearchSuggestions() { } _searchSuggestionsRead = true; if (!_searchSuggestionsKey) { + DEBUG_LOG(("Suggestions: No key.")); return; } FileReadDescriptor suggestions; if (!ReadEncryptedFile(suggestions, _searchSuggestionsKey, _basePath, _localKey)) { + DEBUG_LOG(("Suggestions: Could not read file.")); ClearKey(_searchSuggestionsKey, _basePath); _searchSuggestionsKey = 0; writeMapDelayed(); @@ -2973,6 +2975,8 @@ void Account::readSearchSuggestions() { if (CheckStreamStatus(suggestions.stream)) { _owner->session().topPeers().applyLocal(top); _owner->session().recentPeers().applyLocal(recent); + } else { + DEBUG_LOG(("Suggestions: Could not read content.")); } }