mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add debug logs for recent/top peers resetting.
This commit is contained in:
parent
a74c5a89a6
commit
df2b020b42
3 changed files with 28 additions and 0 deletions
|
@ -95,6 +95,7 @@ QByteArray RecentPeers::serialize() const {
|
||||||
void RecentPeers::applyLocal(QByteArray serialized) {
|
void RecentPeers::applyLocal(QByteArray serialized) {
|
||||||
_list.clear();
|
_list.clear();
|
||||||
if (serialized.isEmpty()) {
|
if (serialized.isEmpty()) {
|
||||||
|
DEBUG_LOG(("Suggestions: Bad RecentPeers local, empty."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto stream = Serialize::ByteArrayReader(serialized);
|
auto stream = Serialize::ByteArrayReader(serialized);
|
||||||
|
@ -102,8 +103,13 @@ void RecentPeers::applyLocal(QByteArray serialized) {
|
||||||
auto count = quint32();
|
auto count = quint32();
|
||||||
stream >> streamAppVersion >> count;
|
stream >> streamAppVersion >> count;
|
||||||
if (!stream.ok()) {
|
if (!stream.ok()) {
|
||||||
|
DEBUG_LOG(("Suggestions: Bad RecentPeers local, not ok."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
DEBUG_LOG(("Suggestions: "
|
||||||
|
"Start RecentPeers read, count: %1, version: %2."
|
||||||
|
).arg(count
|
||||||
|
).arg(streamAppVersion));
|
||||||
_list.reserve(count);
|
_list.reserve(count);
|
||||||
for (auto i = 0; i != int(count); ++i) {
|
for (auto i = 0; i != int(count); ++i) {
|
||||||
const auto peer = Serialize::readPeer(
|
const auto peer = Serialize::readPeer(
|
||||||
|
@ -114,9 +120,15 @@ void RecentPeers::applyLocal(QByteArray serialized) {
|
||||||
_list.push_back(peer);
|
_list.push_back(peer);
|
||||||
} else {
|
} else {
|
||||||
_list.clear();
|
_list.clear();
|
||||||
|
DEBUG_LOG(("Suggestions: Failed RecentPeers reading %1 / %2."
|
||||||
|
).arg(i + 1
|
||||||
|
).arg(count));
|
||||||
|
_list.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DEBUG_LOG(
|
||||||
|
("Suggestions: RecentPeers read OK, count: %1").arg(_list.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
|
@ -274,11 +274,13 @@ QByteArray TopPeers::serialize() const {
|
||||||
|
|
||||||
void TopPeers::applyLocal(QByteArray serialized) {
|
void TopPeers::applyLocal(QByteArray serialized) {
|
||||||
if (_lastReceived) {
|
if (_lastReceived) {
|
||||||
|
DEBUG_LOG(("Suggestions: Skipping TopPeers local, got already."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_list.clear();
|
_list.clear();
|
||||||
_disabled = false;
|
_disabled = false;
|
||||||
if (serialized.isEmpty()) {
|
if (serialized.isEmpty()) {
|
||||||
|
DEBUG_LOG(("Suggestions: Bad TopPeers local, empty."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto stream = Serialize::ByteArrayReader(serialized);
|
auto stream = Serialize::ByteArrayReader(serialized);
|
||||||
|
@ -287,8 +289,14 @@ void TopPeers::applyLocal(QByteArray serialized) {
|
||||||
auto count = quint32();
|
auto count = quint32();
|
||||||
stream >> streamAppVersion >> disabled >> count;
|
stream >> streamAppVersion >> disabled >> count;
|
||||||
if (!stream.ok()) {
|
if (!stream.ok()) {
|
||||||
|
DEBUG_LOG(("Suggestions: Bad TopPeers local, not ok."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
DEBUG_LOG(("Suggestions: "
|
||||||
|
"Start TopPeers read, count: %1, version: %2, disabled: %3."
|
||||||
|
).arg(count
|
||||||
|
).arg(streamAppVersion
|
||||||
|
).arg(disabled));
|
||||||
_list.reserve(count);
|
_list.reserve(count);
|
||||||
for (auto i = 0; i != int(count); ++i) {
|
for (auto i = 0; i != int(count); ++i) {
|
||||||
auto rating = quint64();
|
auto rating = quint64();
|
||||||
|
@ -303,11 +311,15 @@ void TopPeers::applyLocal(QByteArray serialized) {
|
||||||
.rating = DeserializeRating(rating),
|
.rating = DeserializeRating(rating),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
DEBUG_LOG(("Suggestions: "
|
||||||
|
"Failed TopPeers reading %1 / %2.").arg(i + 1).arg(count));
|
||||||
_list.clear();
|
_list.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_disabled = (disabled == 1);
|
_disabled = (disabled == 1);
|
||||||
|
DEBUG_LOG(
|
||||||
|
("Suggestions: TopPeers read OK, count: %1").arg(_list.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
|
@ -2956,11 +2956,13 @@ void Account::readSearchSuggestions() {
|
||||||
}
|
}
|
||||||
_searchSuggestionsRead = true;
|
_searchSuggestionsRead = true;
|
||||||
if (!_searchSuggestionsKey) {
|
if (!_searchSuggestionsKey) {
|
||||||
|
DEBUG_LOG(("Suggestions: No key."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileReadDescriptor suggestions;
|
FileReadDescriptor suggestions;
|
||||||
if (!ReadEncryptedFile(suggestions, _searchSuggestionsKey, _basePath, _localKey)) {
|
if (!ReadEncryptedFile(suggestions, _searchSuggestionsKey, _basePath, _localKey)) {
|
||||||
|
DEBUG_LOG(("Suggestions: Could not read file."));
|
||||||
ClearKey(_searchSuggestionsKey, _basePath);
|
ClearKey(_searchSuggestionsKey, _basePath);
|
||||||
_searchSuggestionsKey = 0;
|
_searchSuggestionsKey = 0;
|
||||||
writeMapDelayed();
|
writeMapDelayed();
|
||||||
|
@ -2973,6 +2975,8 @@ void Account::readSearchSuggestions() {
|
||||||
if (CheckStreamStatus(suggestions.stream)) {
|
if (CheckStreamStatus(suggestions.stream)) {
|
||||||
_owner->session().topPeers().applyLocal(top);
|
_owner->session().topPeers().applyLocal(top);
|
||||||
_owner->session().recentPeers().applyLocal(recent);
|
_owner->session().recentPeers().applyLocal(recent);
|
||||||
|
} else {
|
||||||
|
DEBUG_LOG(("Suggestions: Could not read content."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue