Skip to content

Commit

Permalink
fix download speed of single download
Browse files Browse the repository at this point in the history
  • Loading branch information
kaniol-lck committed Mar 3, 2022
1 parent 5ef96ac commit 6caf37b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/download/qaria2downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/ui/download/qaria2downloaderitemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6caf37b

Please sign in to comment.