diff --git a/dorado/cli/download.cpp b/dorado/cli/download.cpp index d65071d2f..d2adb3332 100644 --- a/dorado/cli/download.cpp +++ b/dorado/cli/download.cpp @@ -75,20 +75,32 @@ int download(int argc, char* argv[]) { return 1; } + try { + fs::remove(directory / "tmp"); + } catch (std::filesystem::filesystem_error const& e) { + std::cerr << "> error: " << e.code().message() << std::endl; + return 1; + } + httplib::Client http(basecaller::URL_ROOT); + http.enable_server_certificate_verification(false); http.set_follow_location(true); for (const auto& [model, url] : basecaller::models) { if (selected_model == "all" || selected_model == model) { std::cerr << " - downloading " << model; auto res = http.Get(url.c_str()); - std::cerr << " [" << res->status << "]" << std::endl; - fs::path archive(directory / (model + ".zip")); - std::ofstream ofs(archive.string()); - ofs << res->body; - ofs.close(); - elz::extractZip(archive, directory); - fs::remove(archive); + if (res != nullptr) { + std::cerr << " [" << res->status << "]" << std::endl; + fs::path archive(directory / (model + ".zip")); + std::ofstream ofs(archive.string()); + ofs << res->body; + ofs.close(); + elz::extractZip(archive, directory); + fs::remove(archive); + } else { + std::cerr << "Failed to download " << model << std::endl; + } } }