diff --git a/repertory/librepertory/src/comm/curl/requests/http_put_file.cpp b/repertory/librepertory/src/comm/curl/requests/http_put_file.cpp index 00260697..565c3fdc 100644 --- a/repertory/librepertory/src/comm/curl/requests/http_put_file.cpp +++ b/repertory/librepertory/src/comm/curl/requests/http_put_file.cpp @@ -58,7 +58,15 @@ auto http_put_file::set_method(CURL *curl, stop_type &stop_requested) const return false; } - auto file_size = read_info->file->size().value_or(0U); + auto opt_size = read_info->file->size(); + if (not opt_size.has_value()) { + utils::error::raise_url_error( + function_name, get_path(), source_path, + std::runtime_error("failed to get file size")); + return false; + } + + auto file_size = opt_size.value(); if (file_size == 0U) { curl_easy_setopt(curl, CURLOPT_INFILESIZE, 0L); return true;