From 299a767d393919f1d007712dd74a38f95038eb78 Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Sat, 11 Apr 2026 14:42:32 -0400 Subject: [PATCH] remove unused code --- pipeline/CMakeLists.txt | 2 - .../includes/web_client/curl_web_client.h | 17 ------ pipeline/includes/web_client/web_client.h | 9 --- pipeline/src/web_client/curl_web_client.cpp | 10 ---- .../curl_web_client_download_to_file.cpp | 59 ------------------- 5 files changed, 97 deletions(-) delete mode 100644 pipeline/src/web_client/curl_web_client.cpp delete mode 100644 pipeline/src/web_client/curl_web_client_download_to_file.cpp diff --git a/pipeline/CMakeLists.txt b/pipeline/CMakeLists.txt index 3a7c37d..a63503f 100644 --- a/pipeline/CMakeLists.txt +++ b/pipeline/CMakeLists.txt @@ -105,8 +105,6 @@ set(SOURCES src/services/wikipedia/get_summary.cpp src/services/wikipedia/fetch_extract.cpp src/web_client/curl_global_state.cpp - src/web_client/curl_web_client.cpp - src/web_client/curl_web_client_download_to_file.cpp src/web_client/curl_web_client_get.cpp src/web_client/curl_web_client_utils.cpp src/web_client/curl_web_client_url_encode.cpp diff --git a/pipeline/includes/web_client/curl_web_client.h b/pipeline/includes/web_client/curl_web_client.h index 75d4046..1586770 100644 --- a/pipeline/includes/web_client/curl_web_client.h +++ b/pipeline/includes/web_client/curl_web_client.h @@ -6,8 +6,6 @@ * @brief libcurl-based WebClient implementation. */ -#include - #include "web_client/web_client.h" /** @@ -36,21 +34,6 @@ class CurlGlobalState { */ class CURLWebClient : public WebClient { public: - /// @brief Constructs a CURL web client. - CURLWebClient(); - - /// @brief Destroys the CURL web client. - ~CURLWebClient() override; - - /** - * @brief Downloads URL contents to a file. - * - * @param url Source URL. - * @param file_path Destination file path. - */ - void DownloadToFile(const std::string& url, - const std::string& file_path) override; - /** * @brief Executes an HTTP GET request. * diff --git a/pipeline/includes/web_client/web_client.h b/pipeline/includes/web_client/web_client.h index affe12f..768468e 100644 --- a/pipeline/includes/web_client/web_client.h +++ b/pipeline/includes/web_client/web_client.h @@ -16,15 +16,6 @@ class WebClient { /// @brief Virtual destructor for polymorphic cleanup. virtual ~WebClient() = default; - /** - * @brief Downloads content from a URL into a file. - * - * @param url Source URL. - * @param file_path Destination file path. - */ - virtual void DownloadToFile(const std::string& url, - const std::string& file_path) = 0; - /** * @brief Executes an HTTP GET request. * diff --git a/pipeline/src/web_client/curl_web_client.cpp b/pipeline/src/web_client/curl_web_client.cpp deleted file mode 100644 index 5bce28e..0000000 --- a/pipeline/src/web_client/curl_web_client.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @file web_client/curl_web_client.cpp - * @brief CURLWebClient constructor and destructor implementation. - */ - -#include "web_client/curl_web_client.h" - -CURLWebClient::CURLWebClient() = default; - -CURLWebClient::~CURLWebClient() = default; diff --git a/pipeline/src/web_client/curl_web_client_download_to_file.cpp b/pipeline/src/web_client/curl_web_client_download_to_file.cpp deleted file mode 100644 index b4cb8f0..0000000 --- a/pipeline/src/web_client/curl_web_client_download_to_file.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file web_client/curl_web_client_download_to_file.cpp - * @brief CURLWebClient::DownloadToFile() implementation. - */ - -#include - -#include -#include -#include -#include - -#include "curl_web_client_utils.h" -#include "web_client/curl_web_client.h" - -// curl write callback that writes to a file stream -static size_t WriteCallbackFile(void* contents, size_t size, size_t nmemb, - void* userp) { - size_t realsize = size * nmemb; - auto* outFile = static_cast(userp); - outFile->write(static_cast(contents), realsize); - return realsize; -} - -void CURLWebClient::DownloadToFile(const std::string& url, - const std::string& file_path) { - auto curl = create_handle(); - - std::ofstream outFile(file_path, std::ios::binary); - if (!outFile.is_open()) { - throw std::runtime_error( - "[CURLWebClient] Cannot open file for writing: " + file_path); - } - - set_common_get_options(curl.get(), url, {30L, 300L}); - curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, WriteCallbackFile); - curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, - static_cast(&outFile)); - - CURLcode res = curl_easy_perform(curl.get()); - outFile.close(); - - if (res != CURLE_OK) { - std::remove(file_path.c_str()); - std::string error = std::string("[CURLWebClient] Download failed: ") + - curl_easy_strerror(res); - throw std::runtime_error(error); - } - - long httpCode = 0; - curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &httpCode); - - if (httpCode != 200) { - std::remove(file_path.c_str()); - std::stringstream ss; - ss << "[CURLWebClient] HTTP error " << httpCode << " for URL " << url; - throw std::runtime_error(ss.str()); - } -}