summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-05-01 23:22:14 +0200
committerCarl Hetherington <cth@carlh.net>2025-07-09 00:35:10 +0200
commit14d4c7b899324766bfac7bd412f4d567340e7752 (patch)
tree592bc0d8bc8b5abe3933457246fc3f3815d1aae0 /src
parent099bd1900672291ed256b54818cb3160ce0c5f7a (diff)
Allow destination path to be empty.
Diffstat (limited to 'src')
-rw-r--r--src/lib/curl_uploader.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/curl_uploader.cc b/src/lib/curl_uploader.cc
index 522ce5f65..a48f2dc2e 100644
--- a/src/lib/curl_uploader.cc
+++ b/src/lib/curl_uploader.cc
@@ -94,11 +94,14 @@ CurlUploader::create_directory(boost::filesystem::path)
void
CurlUploader::upload_file(boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size)
{
- curl_easy_setopt(
- _curl, CURLOPT_URL,
- /* Use generic_string so that we get forward-slashes in the path, even on Windows */
- String::compose("ftp://%1/%2/%3", _destination.host, _destination.path, to.generic_string()).c_str()
- );
+ string url = "ftp://" + _destination.host + "/";
+ if (!_destination.path.empty()) {
+ url += _destination.path + "/";
+ }
+ /* Use generic_string so that we get forward-slashes in the path, even on Windows */
+ url += to.generic_string();
+
+ curl_easy_setopt(_curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(_curl, CURLOPT_RESUME_FROM_LARGE, static_cast<curl_off_t>(-1));
curl_easy_setopt(_curl, CURLOPT_INFILESIZE_LARGE, boost::filesystem::file_size(from));