From 207df6fc406e81bfeebdff7f404bd242ff3f099f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 7 May 2024 06:48:35 +0200 Subject: Merging upstream version 0.12.2. Signed-off-by: Daniel Baumann --- src/url_loader.hh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/url_loader.hh') diff --git a/src/url_loader.hh b/src/url_loader.hh index 799d1a2..bbe582f 100644 --- a/src/url_loader.hh +++ b/src/url_loader.hh @@ -37,20 +37,23 @@ # include # include "base/fs_util.hh" +# include "base/paths.hh" # include "curl_looper.hh" class url_loader : public curl_request { public: url_loader(const std::string& url) : curl_request(url) { - auto tmp_res = lnav::filesystem::open_temp_file( - ghc::filesystem::temp_directory_path() / "lnav.url.XXXXXX"); + std::error_code errc; + ghc::filesystem::create_directories(lnav::paths::workdir(), errc); + auto tmp_res = lnav::filesystem::open_temp_file(lnav::paths::workdir() + / "url.XXXXXX"); if (tmp_res.isErr()) { return; } auto tmp_pair = tmp_res.unwrap(); - ghc::filesystem::remove(tmp_pair.first); + this->ul_path = tmp_pair.first; this->ul_fd = std::move(tmp_pair.second); curl_easy_setopt(this->cr_handle, CURLOPT_URL, this->cr_name.c_str()); @@ -60,9 +63,7 @@ public: curl_easy_setopt(this->cr_handle, CURLOPT_BUFFERSIZE, 128L * 1024L); } - int get_fd() const { return this->ul_fd.get(); } - - auto_fd copy_fd() const { return this->ul_fd.dup(); } + ghc::filesystem::path get_path() const { return this->ul_path; } long complete(CURLcode result) { @@ -93,7 +94,8 @@ public: time(¤t_time); if (file_time == -1 - || (current_time - file_time) < FOLLOW_IF_MODIFIED_SINCE) { + || (current_time - file_time) < FOLLOW_IF_MODIFIED_SINCE) + { char range[64]; struct stat st; off_t start; @@ -142,6 +144,7 @@ private: return retval; } + ghc::filesystem::path ul_path; auto_fd ul_fd; off_t ul_resume_offset{0}; }; -- cgit v1.2.3