From ca2a44f4e7c40caa2d3f8117920e29a442f9b938 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sat, 18 Feb 2017 23:05:53 -0600 Subject: [PATCH] Misc. changes --- SiaDrive.Api/SiaRenter.cpp | 26 +++++++++++++++++--------- SiaDrive/SiaDrive.htm | 24 ++++++++++++------------ SiaDrive/SiaDriveDlg.cpp | 4 ++-- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/SiaDrive.Api/SiaRenter.cpp b/SiaDrive.Api/SiaRenter.cpp index ec91763..af67754 100644 --- a/SiaDrive.Api/SiaRenter.cpp +++ b/SiaDrive.Api/SiaRenter.cpp @@ -80,18 +80,26 @@ void CSiaApi::_CSiaRenter::AutoThreadCallback(const CSiaCurl& siaCurl) fileTree->BuildTree(result); auto fileList = fileTree->GetFileList(); - std::uint64_t total = std::accumulate(std::next(fileList.begin()), fileList.end(), fileList[0]->GetFileSize(), [](const std::uint64_t& sz, const CSiaFilePtr& file) + if (fileList.size()) { - return sz + file->GetFileSize(); - }); + std::uint64_t total = std::accumulate(std::next(fileList.begin()), fileList.end(), fileList[0]->GetFileSize(), [](const std::uint64_t& sz, const CSiaFilePtr& file) + { + return sz + file->GetFileSize(); + }); - std::uint32_t totalProgress = std::accumulate(std::next(fileList.begin()), fileList.end(), fileList[0]->GetUploadProgress(), [](const std::uint32_t& progress, const CSiaFilePtr& file) + 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 { - return progress + file->GetUploadProgress(); - }) / fileList.size(); - - SetTotalUsedBytes(total); - SetTotalUploadProgress(totalProgress); + SetTotalUsedBytes(0); + SetTotalUploadProgress(100); + } } else { diff --git a/SiaDrive/SiaDrive.htm b/SiaDrive/SiaDrive.htm index 0ebf68f..7dbd7ce 100644 --- a/SiaDrive/SiaDrive.htm +++ b/SiaDrive/SiaDrive.htm @@ -237,44 +237,44 @@