fix(net): fix emit signals in download & upload task

Signed-off-by: seth <getchoo@tuta.io>
This commit is contained in:
seth 2023-06-25 18:49:50 -04:00
parent 4ea0a567bc
commit c49ee87857
No known key found for this signature in database
GPG Key ID: D31BD0D494BBEE86
2 changed files with 12 additions and 12 deletions

View File

@ -117,7 +117,7 @@ void Download::executeTask()
switch (m_state) { switch (m_state) {
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();
emitSucceeded(); emit succeeded();
return; return;
case State::Running: case State::Running:
qCDebug(taskDownloadLogC) << getUid().toString() << "Downloading " << m_url.toString(); qCDebug(taskDownloadLogC) << getUid().toString() << "Downloading " << m_url.toString();
@ -294,19 +294,19 @@ void Download::downloadFinished()
qCDebug(taskDownloadLogC) << getUid().toString() << "Download failed but we are allowed to proceed:" << m_url.toString(); qCDebug(taskDownloadLogC) << getUid().toString() << "Download failed but we are allowed to proceed:" << m_url.toString();
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emitSucceeded(); emit succeeded();
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();
emitFailed(""); emit failed("");
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();
emitAborted(); emit aborted();
return; return;
} }
@ -323,13 +323,13 @@ void Download::downloadFinished()
qCDebug(taskDownloadLogC) << getUid().toString() << "Download failed to finalize:" << m_url.toString(); qCDebug(taskDownloadLogC) << getUid().toString() << "Download failed to finalize:" << m_url.toString();
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emitFailed(""); emit failed("");
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();
emitSucceeded(); emit succeeded();
} }
void Download::downloadReadyRead() void Download::downloadReadyRead()

View File

@ -157,19 +157,19 @@ void Upload::downloadFinished()
qCDebug(taskUploadLogC) << getUid().toString() << "Upload failed but we are allowed to proceed:" << m_url.toString(); qCDebug(taskUploadLogC) << getUid().toString() << "Upload failed but we are allowed to proceed:" << m_url.toString();
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emitSucceeded(); emit succeeded();
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();
emitFailed(""); emit failed("");
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();
emitAborted(); emit aborted();
return; return;
} }
@ -186,12 +186,12 @@ void Upload::downloadFinished()
qCDebug(taskUploadLogC) << getUid().toString() << "Upload failed to finalize:" << m_url.toString(); qCDebug(taskUploadLogC) << getUid().toString() << "Upload failed to finalize:" << m_url.toString();
m_sink->abort(); m_sink->abort();
m_reply.reset(); m_reply.reset();
emitFailed(""); emit failed("");
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();
emitSucceeded(); emit succeeded();
} }
void Upload::downloadReadyRead() void Upload::downloadReadyRead()
@ -208,7 +208,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();
emitAborted(); emit aborted();
return; return;
} }
QNetworkRequest request(m_url); QNetworkRequest request(m_url);