diff --git a/chump-cli/main.cpp b/chump-cli/main.cpp index 97a6ec9..eb5f2c5 100644 --- a/chump-cli/main.cpp +++ b/chump-cli/main.cpp @@ -179,7 +179,6 @@ int main(int argc, const char **argv) { return 0; } - // if the manifest isn't loading properly, only allow `chump list -u`. // this is an escape hatch, because failing to parse manifest.json will // result in an exception and the program won't continue. diff --git a/src/fetch.cpp b/src/fetch.cpp index b29eed3..afd1981 100644 --- a/src/fetch.cpp +++ b/src/fetch.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include "fetch.h" @@ -31,8 +32,9 @@ int progressCallback(void *clientp, double dltotal, double dlnow, } // metadata for the progress bar - // Calculate progress percentage - double progress = (dlnow > 0) ? ((double)dlnow / (double)dltotal) : 0.0; + double progress = 0; + if (dltotal >= 1.0) + progress = (dlnow > 0) ? ((double)dlnow / (double)dltotal) : 0.0; int bar_width = CHUMP_PROGRESS_BAR_WIDTH; // Width of the progress bar int filled_width = progress * bar_width; @@ -73,7 +75,9 @@ int progressCallback(void *clientp, double dltotal, double dlnow, else line += " "; } - line += string("] ") + std::to_string((int)(progress * 100 + .5)) + "%"; + + line += string("] ") + std::to_string((int)(progress * 100 + .5)) + + "% "; std::cerr << "\r" << line.c_str(); return 0; diff --git a/src/util.cpp b/src/util.cpp index 9dc1e25..83fc8b5 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -167,8 +167,9 @@ std::string hash_file(fs::path filename) { bool validate_manifest(fs::path manifest_path) { if (!fs::exists(manifest_path)) { - std::cerr << "[chump]: unable to find package list (manifest.json), fetching..." - << std::endl; + std::cerr + << "[chump]: unable to find package list (manifest.json), fetching..." + << std::endl; return false; } @@ -231,7 +232,6 @@ bool unzipFile(const std::string &zipPath, const std::string &outputDir) { if (filename[strlen(filename) - 1] == '/') { std::filesystem::create_directories(fullPath); } else { - std::cerr << "[chump]: installing \"" << fullPath << "\"" << std::endl; // Extract file unzOpenCurrentFile(zipFile);