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 @@