From a77fd7568777b1971daaa5ffbb49d32e8e632a32 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 25 Oct 2024 10:18:29 -0500 Subject: [PATCH] refactor --- .../src/comm/curl/requests/http_put_file.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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;