From 6caf37becc6fd545a9c90ea2c48757187c411cb2 Mon Sep 17 00:00:00 2001 From: kaniol-lck <375520360@qq.com> Date: Thu, 3 Mar 2022 23:22:29 +0800 Subject: [PATCH] fix download speed of single download --- src/download/qaria2downloader.cpp | 7 ++++++- src/ui/download/qaria2downloaderitemwidget.cpp | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/download/qaria2downloader.cpp b/src/download/qaria2downloader.cpp index 35ab4563..35b1de1a 100644 --- a/src/download/qaria2downloader.cpp +++ b/src/download/qaria2downloader.cpp @@ -23,7 +23,7 @@ void QAria2Downloader::deleteDownloadHandle() void QAria2Downloader::update() { - if(!handle_) handle_ = aria2::getDownloadHandle(QAria2::qaria2()->session(), gid_); + handle_ = aria2::getDownloadHandle(QAria2::qaria2()->session(), gid_); if(!handle_) return; if(status_ != aria2::DOWNLOAD_ACTIVE) return; if(auto files = handle_->getFiles(); !files.empty()){ @@ -35,6 +35,11 @@ void QAria2Downloader::update() } emit downloadProgress(handle_->getCompletedLength(), handle_->getTotalLength()); emit downloadSpeed(handle_->getDownloadSpeed(), handle_->getUploadSpeed()); + qDebug() << QString::fromStdString(aria2::gidToHex(gid_)) + << handle_->getCompletedLength() << handle_->getTotalLength() + << handle_->getDownloadSpeed() << handle_->getUploadSpeed() + << handle_->getConnections() << handle_->getNumPieces() + << handle_->getPieceLength() << handle_->getStatus(); } aria2::DownloadStatus QAria2Downloader::status() const diff --git a/src/ui/download/qaria2downloaderitemwidget.cpp b/src/ui/download/qaria2downloaderitemwidget.cpp index 066b15b3..09bcb482 100644 --- a/src/ui/download/qaria2downloaderitemwidget.cpp +++ b/src/ui/download/qaria2downloaderitemwidget.cpp @@ -57,6 +57,8 @@ void QAria2DownloaderItemWidget::onInfoChanged() void QAria2DownloaderItemWidget::refreshStatus(int status) { + if(status != aria2::DOWNLOAD_ACTIVE) + downloadSpeed(0, 0); QString text; switch (status) { case aria2::DOWNLOAD_ACTIVE: