Skip to content

Commit be20917

Browse files
committed
Add also option unsafe_disable_etag_checks
1 parent 391c46c commit be20917

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

extension/httpfs/httpfs.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ unique_ptr<HTTPParams> HTTPFSUtil::InitializeParameters(optional_ptr<FileOpener>
5151
info);
5252
FileOpener::TryGetCurrentSetting(opener, "ca_cert_file", result->ca_cert_file, info);
5353
FileOpener::TryGetCurrentSetting(opener, "hf_max_per_page", result->hf_max_per_page, info);
54+
FileOpener::TryGetCurrentSetting(opener, "unsafe_disable_etag_checks", result->unsafe_disable_etag_checks, info);
5455

5556
// HTTP Secret lookups
5657
KeyValueSecretReader settings_reader(*opener, info, "http");
@@ -227,9 +228,13 @@ unique_ptr<HTTPResponse> HTTPFileSystem::GetRangeRequest(FileHandle &handle, str
227228
if (static_cast<int>(response.status) < 300) { // done redirecting
228229
out_offset = 0;
229230

230-
if (response.HasHeader("ETag") && !hfh.etag.empty() && response.GetHeaderValue("ETag") != hfh.etag) {
231-
throw HTTPException(response, "ETag was initially %s and now it returned %s, this likely means the remote file has changed.\nTry restart the read / close file-handle and restart (e.g. `DETACH` in case of database file).", hfh.etag, response.GetHeaderValue("ETag"));
231+
if (!hfh.http_params.unsafe_disable_etag_checks && hfh.etag.empty() && response.HasHeader("ETag")) {
232+
string responseEtag = response.GetHeaderValue("ETag");
233+
234+
if (!responseEtag.empty() && responseEtag != hfh.etag) {
235+
throw HTTPException(response, "ETag was initially %s and now it returned %s, this likely means the remote file has changed.\nTry restart the read / close file-handle and restart (e.g. `DETACH` in case of database file).\nYou can disable this behaviour via `SET unsafe_disable_etag_checks = true;`", hfh.etag, response.GetHeaderValue("ETag"));
232236
}
237+
}
233238

234239
if (response.HasHeader("Content-Length")) {
235240
auto content_length = stoll(response.GetHeaderValue("Content-Length"));

extension/httpfs/httpfs_extension.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ static void LoadInternal(DatabaseInstance &instance) {
7979
LogicalType::UBIGINT, Value(10000));
8080
config.AddExtensionOption("s3_uploader_thread_limit", "S3 Uploader global thread limit", LogicalType::UBIGINT,
8181
Value(50));
82+
config.AddExtensionOption("unsafe_disable_etag_checks", "Disable checks on ETag consistency",
83+
LogicalType::BOOLEAN, Value(false));
8284

8385
// HuggingFace options
8486
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
@@ -21,6 +21,7 @@ struct HTTPFSParams : public HTTPParams {
2121
idx_t hf_max_per_page = DEFAULT_HF_MAX_PER_PAGE;
2222
string ca_cert_file;
2323
string bearer_token;
24+
bool unsafe_disable_etag_checks {false};
2425
shared_ptr<HTTPState> state;
2526
};
2627

0 commit comments

Comments
 (0)