From 74bd4eed7c12aa0e6694094878c6e1ad7ba87f76 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 6 Oct 2026 13:03:53 +0200 Subject: [PATCH] Keep outdated avatar transfers from delaying new references --- tools/chatgui/src/avatars/avatarmanager.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/chatgui/src/avatars/avatarmanager.cpp b/tools/chatgui/src/avatars/avatarmanager.cpp index 9ba90734..38b9b76d 100644 --- a/tools/chatgui/src/avatars/avatarmanager.cpp +++ b/tools/chatgui/src/avatars/avatarmanager.cpp @@ -242,9 +242,11 @@ void AvatarManager::scheduleOwn(quint64 group) { } void AvatarManager::enqueue(const Job& job) { - for (const auto& old : m_jobs) if ((old.upload == job.upload && old.ref.group == job.ref.group && old.ref.owner == job.ref.owner) || + for (const auto& old : m_jobs) if ((old.upload == job.upload && old.ref.group == job.ref.group && old.ref.owner == job.ref.owner && + (job.upload || old.ref.hash == job.ref.hash)) || (!job.upload && !old.upload && old.ref.hash == job.ref.hash)) return; - for (const auto& old : m_queue) if ((old.upload == job.upload && old.ref.group == job.ref.group && old.ref.owner == job.ref.owner) || + for (const auto& old : m_queue) if ((old.upload == job.upload && old.ref.group == job.ref.group && old.ref.owner == job.ref.owner && + (job.upload || old.ref.hash == job.ref.hash)) || (!job.upload && !old.upload && old.ref.hash == job.ref.hash)) return; if (job.upload) m_queue.prepend(job); else m_queue.enqueue(job); } @@ -349,6 +351,11 @@ void AvatarManager::onPublished(const uint8_t* data, int length) { void AvatarManager::finish(quint64 id, int status) { const Job job = m_jobs.take(id); const QString context = key(job.ref.group, job.ref.owner); + const Ref current = m_refs.value(context); + if ((job.upload && job.generation != m_generation) || (!job.upload && + (current.hash != job.ref.hash || current.server != job.ref.server))) { + QTimer::singleShot(0, this, &AvatarManager::pump); return; + } if (status && status != MF_CANCELLED) { unsigned attempt = qMin(6u, m_failures.value(context) + 1); m_failures[context] = attempt; m_retry[context] = QDateTime::currentMSecsSinceEpoch() + (5000LL << (attempt - 1));