|
|
|
|
@ -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)); |
|
|
|
|
|