From a1f0ca5b20b759f807fd993cc78bf9ba7fe31266 Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Thu, 2 Apr 2026 18:06:40 -0400 Subject: [PATCH] Refactor DataDownloader and CURLWebClient: update constructor and modify FileExists method signature --- pipeline/includes/data_downloader.h | 4 ++-- pipeline/src/curl_web_client.cpp | 4 ++-- pipeline/src/data_downloader.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pipeline/includes/data_downloader.h b/pipeline/includes/data_downloader.h index dae783e..def79ec 100644 --- a/pipeline/includes/data_downloader.h +++ b/pipeline/includes/data_downloader.h @@ -11,7 +11,7 @@ class DataDownloader { public: /// @brief Initializes global curl state used by this downloader. - DataDownloader(std::shared_ptr webClient); + explicit DataDownloader(std::shared_ptr webClient); /// @brief Cleans up global curl state. ~DataDownloader(); @@ -23,7 +23,7 @@ public: ); private: - bool FileExists(const std::string &filePath) const; + static bool FileExists(const std::string &filePath) ; std::shared_ptr m_webClient; }; diff --git a/pipeline/src/curl_web_client.cpp b/pipeline/src/curl_web_client.cpp index 9a94c55..2201dec 100644 --- a/pipeline/src/curl_web_client.cpp +++ b/pipeline/src/curl_web_client.cpp @@ -17,7 +17,7 @@ CurlGlobalState::~CurlGlobalState() { curl_global_cleanup(); } namespace { // curl write callback that appends response data into a std::string -static size_t WriteCallbackString(void *contents, size_t size, size_t nmemb, +size_t WriteCallbackString(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; auto *s = static_cast(userp); @@ -26,7 +26,7 @@ static size_t WriteCallbackString(void *contents, size_t size, size_t nmemb, } // curl write callback that writes to a file stream -static size_t WriteCallbackFile(void *contents, size_t size, size_t nmemb, + size_t WriteCallbackFile(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; auto *outFile = static_cast(userp); diff --git a/pipeline/src/data_downloader.cpp b/pipeline/src/data_downloader.cpp index 5060433..7d141f0 100644 --- a/pipeline/src/data_downloader.cpp +++ b/pipeline/src/data_downloader.cpp @@ -11,7 +11,7 @@ DataDownloader::DataDownloader(std::shared_ptr webClient) DataDownloader::~DataDownloader() {} -bool DataDownloader::FileExists(const std::string &filePath) const { +bool DataDownloader::FileExists(const std::string &filePath) { return std::filesystem::exists(filePath); }