Skip to content

Commit 7b09112

Browse files
authored
Merge pull request #67 from Tmonster/allow_direct_complete_download
Allow complete downloads to happen without first making a GET request
2 parents 7ce5308 + 9fc5a2e commit 7b09112

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

extension/httpfs/httpfs.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ void TimestampToTimeT(timestamp_t timestamp, time_t &result) {
279279
HTTPFileHandle::HTTPFileHandle(FileSystem &fs, const OpenFileInfo &file, FileOpenFlags flags,
280280
unique_ptr<HTTPParams> params_p)
281281
: FileHandle(fs, file.path, flags), params(std::move(params_p)), http_params(params->Cast<HTTPFSParams>()),
282-
flags(flags), length(0), buffer_available(0), buffer_idx(0), file_offset(0), buffer_start(0), buffer_end(0) {
282+
flags(flags), length(0), force_full_download(false), buffer_available(0), buffer_idx(0), file_offset(0), buffer_start(0), buffer_end(0) {
283283
// check if the handle has extended properties that can be set directly in the handle
284284
// if we have these properties we don't need to do a head request to obtain them later
285285
if (file.extended_info) {
@@ -296,6 +296,10 @@ HTTPFileHandle::HTTPFileHandle(FileSystem &fs, const OpenFileInfo &file, FileOpe
296296
if (fs_entry != info.end()) {
297297
length = fs_entry->second.GetValue<uint64_t>();
298298
}
299+
auto force_full_download_entry = info.find("force_full_download");
300+
if (force_full_download_entry != info.end()) {
301+
force_full_download = force_full_download_entry->second.GetValue<bool>();
302+
}
299303
if (lm_entry != info.end() && etag_entry != info.end() && fs_entry != info.end()) {
300304
// we found all relevant entries (last_modified, etag and file size)
301305
// skip head request
@@ -595,8 +599,8 @@ optional_idx TryParseContentLength(const HTTPHeaders &headers) {
595599
}
596600

597601
void HTTPFileHandle::LoadFileInfo() {
598-
if (initialized) {
599-
// already initialized
602+
if (initialized || force_full_download) {
603+
// already initialized or we specifically do not want to perform a head request and just run a direct download
600604
return;
601605
}
602606
auto &hfs = file_system.Cast<HTTPFileSystem>();
@@ -685,7 +689,7 @@ void HTTPFileHandle::Initialize(optional_ptr<FileOpener> opener) {
685689
LoadFileInfo();
686690

687691
if (flags.OpenForReading()) {
688-
if (http_params.state && length == 0) {
692+
if ((http_params.state && length == 0) || force_full_download) {
689693
FullDownload(hfs, should_write_cache);
690694
}
691695
if (should_write_cache) {

extension/httpfs/include/httpfs.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class HTTPFileHandle : public FileHandle {
4848
idx_t length;
4949
time_t last_modified;
5050
string etag;
51+
bool force_full_download;
5152
bool initialized = false;
5253

5354
// When using full file download, the full file will be written to a cached file handle

0 commit comments

Comments
 (0)