1
0

Upload percentage

This commit is contained in:
Scott E. Graves
2017-02-18 22:06:50 -06:00
parent a782feefbe
commit 3c18bf8b69
7 changed files with 89 additions and 5 deletions

View File

@@ -51,7 +51,8 @@ CSiaApi::_CSiaRenter::_CSiaRenter(const CSiaCurl& siaCurl) :
_Funds(0),
_Hosts(0),
_Unspent(0),
_TotalUsedBytes(0)
_TotalUsedBytes(0),
_TotalUploadProgress(100)
{
StartAutoThread();
}
@@ -83,11 +84,19 @@ void CSiaApi::_CSiaRenter::AutoThreadCallback(const CSiaCurl& siaCurl)
{
return sz + file->GetFileSize();
});
SetTotalUsedBytes(total);
std::uint32_t totalProgress = std::accumulate(std::next(fileList.begin()), fileList.end(), fileList[0]->GetUploadProgress(), [](const std::uint32_t& progress, const CSiaFilePtr& file)
{
return progress + file->GetUploadProgress();
}) / fileList.size();
SetTotalUsedBytes(total);
SetTotalUploadProgress(totalProgress);
}
else
{
SetTotalUsedBytes(0);
SetTotalUploadProgress(100);
}
}
else
@@ -96,6 +105,7 @@ void CSiaApi::_CSiaRenter::AutoThreadCallback(const CSiaCurl& siaCurl)
SetHosts(0);
SetUnspent(0);
SetTotalUsedBytes(0);
SetTotalUploadProgress(100);
}
}