fix: ensure finished signal is emited

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers 2023-06-25 16:13:26 -07:00
parent c49ee87857
commit b142407b21
No known key found for this signature in database
GPG Key ID: E10E321EB160949B
2 changed files with 12 additions and 0 deletions

View File

@ -118,6 +118,7 @@ void Download::executeTask()
case State::Succeeded: case State::Succeeded:
qCDebug(taskDownloadLogC) << getUid().toString() << "Download cache hit " << m_url.toString(); qCDebug(taskDownloadLogC) << getUid().toString() << "Download cache hit " << m_url.toString();
emit succeeded(); emit succeeded();
emit finished();
return; return;
case State::Running: case State::Running:
qCDebug(taskDownloadLogC) << getUid().toString() << "Downloading " << m_url.toString(); qCDebug(taskDownloadLogC) << getUid().toString() << "Downloading " << m_url.toString();
@ -295,18 +296,21 @@ void Download::downloadFinished()
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emit succeeded(); emit succeeded();
emit finished();
return; return;
} else if (m_state == State::Failed) { } else if (m_state == State::Failed) {
qCDebug(taskDownloadLogC) << getUid().toString() << "Download failed in previous step:" << m_url.toString(); qCDebug(taskDownloadLogC) << getUid().toString() << "Download failed in previous step:" << m_url.toString();
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emit failed(""); emit failed("");
emit finished();
return; return;
} else if (m_state == State::AbortedByUser) { } else if (m_state == State::AbortedByUser) {
qCDebug(taskDownloadLogC) << getUid().toString() << "Download aborted in previous step:" << m_url.toString(); qCDebug(taskDownloadLogC) << getUid().toString() << "Download aborted in previous step:" << m_url.toString();
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emit aborted(); emit aborted();
emit finished();
return; return;
} }
@ -324,12 +328,14 @@ void Download::downloadFinished()
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emit failed(""); emit failed("");
emit finished();
return; return;
} }
m_reply.reset(); m_reply.reset();
qCDebug(taskDownloadLogC) << getUid().toString() << "Download succeeded:" << m_url.toString(); qCDebug(taskDownloadLogC) << getUid().toString() << "Download succeeded:" << m_url.toString();
emit succeeded(); emit succeeded();
emit finished();
} }
void Download::downloadReadyRead() void Download::downloadReadyRead()

View File

@ -158,18 +158,21 @@ void Upload::downloadFinished()
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emit succeeded(); emit succeeded();
emit finished();
return; return;
} else if (m_state == State::Failed) { } else if (m_state == State::Failed) {
qCDebug(taskUploadLogC) << getUid().toString() << "Upload failed in previous step:" << m_url.toString(); qCDebug(taskUploadLogC) << getUid().toString() << "Upload failed in previous step:" << m_url.toString();
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emit failed(""); emit failed("");
emit finished();
return; return;
} else if (m_state == State::AbortedByUser) { } else if (m_state == State::AbortedByUser) {
qCDebug(taskUploadLogC) << getUid().toString() << "Upload aborted in previous step:" << m_url.toString(); qCDebug(taskUploadLogC) << getUid().toString() << "Upload aborted in previous step:" << m_url.toString();
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emit aborted(); emit aborted();
emit finished();
return; return;
} }
@ -187,11 +190,13 @@ void Upload::downloadFinished()
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emit failed(""); emit failed("");
emit finished();
return; return;
} }
m_reply.reset(); m_reply.reset();
qCDebug(taskUploadLogC) << getUid().toString() << "Upload succeeded:" << m_url.toString(); qCDebug(taskUploadLogC) << getUid().toString() << "Upload succeeded:" << m_url.toString();
emit succeeded(); emit succeeded();
emit finished();
} }
void Upload::downloadReadyRead() void Upload::downloadReadyRead()
@ -209,6 +214,7 @@ void Upload::executeTask()
if (m_state == State::AbortedByUser) { if (m_state == State::AbortedByUser) {
qCWarning(taskUploadLogC) << getUid().toString() << "Attempt to start an aborted Upload:" << m_url.toString(); qCWarning(taskUploadLogC) << getUid().toString() << "Attempt to start an aborted Upload:" << m_url.toString();
emit aborted(); emit aborted();
emit finished();
return; return;
} }
QNetworkRequest request(m_url); QNetworkRequest request(m_url);