http: Use Path for the download file.

This commit is contained in:
Unknown W. Brackets
2021-05-14 22:46:03 -07:00
parent ed2ade4e22
commit 2a9170a2ea
9 changed files with 29 additions and 24 deletions
+7 -7
View File
@@ -457,7 +457,7 @@ int Client::ReadResponseEntity(net::Buffer *readbuf, const std::vector<std::stri
return 0;
}
Download::Download(const std::string &url, const std::string &outfile)
Download::Download(const std::string &url, const Path &outfile)
: progress_(&cancelled_), url_(url), outfile_(outfile) {
}
@@ -552,12 +552,12 @@ void Download::Do() {
}
if (resultCode == 200) {
INFO_LOG(IO, "Completed downloading %s to %s", url_.c_str(), outfile_.empty() ? "memory" : outfile_.c_str());
if (!outfile_.empty() && !buffer_.FlushToFile(outfile_.c_str())) {
ERROR_LOG(IO, "Failed writing download to %s", outfile_.c_str());
INFO_LOG(IO, "Completed downloading %s to %s", url_.c_str(), outfile_.empty() ? "memory" : outfile_.ToVisualString().c_str());
if (!outfile_.empty() && !buffer_.FlushToFile(outfile_)) {
ERROR_LOG(IO, "Failed writing download to %s", outfile_.ToVisualString().c_str());
}
} else {
ERROR_LOG(IO, "Error downloading %s to %s: %i", url_.c_str(), outfile_.c_str(), resultCode);
ERROR_LOG(IO, "Error downloading %s to %s: %i", url_.c_str(), outfile_.ToVisualString().c_str(), resultCode);
}
resultCode_ = resultCode;
}
@@ -569,7 +569,7 @@ void Download::Do() {
completed_ = true;
}
std::shared_ptr<Download> Downloader::StartDownload(const std::string &url, const std::string &outfile) {
std::shared_ptr<Download> Downloader::StartDownload(const std::string &url, const Path &outfile) {
std::shared_ptr<Download> dl(new Download(url, outfile));
downloads_.push_back(dl);
dl->Start();
@@ -578,7 +578,7 @@ std::shared_ptr<Download> Downloader::StartDownload(const std::string &url, cons
std::shared_ptr<Download> Downloader::StartDownloadWithCallback(
const std::string &url,
const std::string &outfile,
const Path &outfile,
std::function<void(Download &)> callback) {
std::shared_ptr<Download> dl(new Download(url, outfile));
dl->SetCallback(callback);