fix: allow aborting upload tasks

This maintains the same behaviour as the Download task.

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-06-06 20:16:13 -03:00
parent 882c82f82c
commit 91776311c7
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 12 additions and 0 deletions

View File

@ -43,6 +43,16 @@
namespace Net { namespace Net {
bool Upload::abort()
{
if (m_reply) {
m_reply->abort();
} else {
m_state = State::AbortedByUser;
}
return true;
}
void Upload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { void Upload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
setProgress(bytesReceived, bytesTotal); setProgress(bytesReceived, bytesTotal);
} }

View File

@ -46,6 +46,8 @@ namespace Net {
public: public:
static Upload::Ptr makeByteArray(QUrl url, QByteArray *output, QByteArray m_post_data); static Upload::Ptr makeByteArray(QUrl url, QByteArray *output, QByteArray m_post_data);
auto abort() -> bool override;
auto canAbort() const -> bool override { return true; };
protected slots: protected slots:
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) override; void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) override;