Skip to content

Commit 4135c19

Browse files
authored
Merge pull request #116 from duckdb/main
Merge `main` into `v1.4-andium`
2 parents 7df8b5c + 8671fc0 commit 4135c19

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

extension/httpfs/httpfs.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ unique_ptr<HTTPParams> HTTPFSUtil::InitializeParameters(optional_ptr<FileOpener>
5555
info);
5656
FileOpener::TryGetCurrentSetting(opener, "ca_cert_file", result->ca_cert_file, info);
5757
FileOpener::TryGetCurrentSetting(opener, "hf_max_per_page", result->hf_max_per_page, info);
58+
FileOpener::TryGetCurrentSetting(opener, "unsafe_disable_etag_checks", result->unsafe_disable_etag_checks, info);
5859

5960
// HTTP Secret lookups
6061
KeyValueSecretReader settings_reader(*opener, info, "http");
@@ -230,6 +231,17 @@ unique_ptr<HTTPResponse> HTTPFileSystem::GetRangeRequest(FileHandle &handle, str
230231
}
231232
if (static_cast<int>(response.status) < 300) { // done redirecting
232233
out_offset = 0;
234+
235+
if (!hfh.http_params.unsafe_disable_etag_checks && hfh.etag.empty() && response.HasHeader("ETag")) {
236+
string responseEtag = response.GetHeaderValue("ETag");
237+
238+
if (!responseEtag.empty() && responseEtag != hfh.etag) {
239+
throw HTTPException(response, "ETag was initially %s and now it returned %s, this likely means the remote file has changed.\nTry to restart the read or close the file-handle and read the file again (e.g. `DETACH` in the file is a database file).\nYou can disable checking etags via `SET unsafe_disable_etag_checks = true;`", hfh.etag, response.GetHeaderValue("ETag"));
240+
}
241+
}
242+
243+
244+
233245
if (response.HasHeader("Content-Length")) {
234246
auto content_length = stoll(response.GetHeaderValue("Content-Length"));
235247
if ((idx_t)content_length != buffer_out_len) {

extension/httpfs/httpfs_extension.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ static void LoadInternal(ExtensionLoader &loader) {
8181
LogicalType::UBIGINT, Value(10000));
8282
config.AddExtensionOption("s3_uploader_thread_limit", "S3 Uploader global thread limit", LogicalType::UBIGINT,
8383
Value(50));
84+
config.AddExtensionOption("unsafe_disable_etag_checks", "Disable checks on ETag consistency",
85+
LogicalType::BOOLEAN, Value(false));
8486

8587
// HuggingFace options
8688
config.AddExtensionOption("hf_max_per_page", "Debug option to limit number of items returned in list requests",

extension/httpfs/include/httpfs_client.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct HTTPFSParams : public HTTPParams {
2525
idx_t hf_max_per_page = DEFAULT_HF_MAX_PER_PAGE;
2626
string ca_cert_file;
2727
string bearer_token;
28+
bool unsafe_disable_etag_checks {false};
2829
shared_ptr<HTTPState> state;
2930
};
3031

0 commit comments

Comments
 (0)