Skip to content

Commit

Permalink
Merge commit 'a976b71c3c1996e02a5a0469013ba4762e7a8a85' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
maksis committed Feb 8, 2016
2 parents c307dbb + a976b71 commit badf5f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions airdcpp-webapi/api/TransferApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ namespace webserver {
if (timeSinceStarted < 1000) {
t->setStatusString(aIsDownload ? STRING(DOWNLOAD_STARTING) : STRING(UPLOAD_STARTING));
} else {
auto pct = t->getSize() > 0 ? (double)t->getBytesTransferred() * 100.0 / (double)t->getSize() : 0;
t->setStatusString(STRING_F(RUNNING_PCT, pct));
t->setStatusString(STRING_F(RUNNING_PCT, t->getPercentage()));
}

view.onItemUpdated(t, { PROP_STATUS, PROP_BYTES_TRANSFERRED, PROP_SPEED, PROP_SECONDS_LEFT });
Expand Down
6 changes: 5 additions & 1 deletion airdcpp-webapi/api/TransferInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace webserver {
public:
enum ItemState {
STATE_WAITING,
STATE_RUNNING,
STATE_FAILED,
STATE_RUNNING,
STATE_FINISHED,
STATE_LAST,
};
Expand Down Expand Up @@ -65,6 +65,10 @@ namespace webserver {
return token;
}

double getPercentage() const noexcept {
return size > 0 ? static_cast<double>(bytesTransferred) * 100.0 / static_cast<double>(size) : 0;
}

const string& getStringToken() const noexcept {
return stringToken;
}
Expand Down
2 changes: 1 addition & 1 deletion airdcpp-webapi/api/TransferUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace webserver {
}

if (a->getState() == TransferInfo::STATE_RUNNING) {
return compare(a->getBytesTransferred(), b->getBytesTransferred());
return compare(a->getPercentage(), b->getPercentage());
}

return Util::stricmp(a->getStatusString(), b->getStatusString());
Expand Down

0 comments on commit badf5f8

Please sign in to comment.