Skip to content

Commit 391c46c

Browse files
committed
When a HTTPFIleHandle has an Etag, and that changes over time, consider the read unreliable
1 parent caf527f commit 391c46c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

extension/httpfs/httpfs.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ unique_ptr<HTTPResponse> HTTPFileSystem::GetRangeRequest(FileHandle &handle, str
226226
}
227227
if (static_cast<int>(response.status) < 300) { // done redirecting
228228
out_offset = 0;
229+
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"));
232+
}
233+
229234
if (response.HasHeader("Content-Length")) {
230235
auto content_length = stoll(response.GetHeaderValue("Content-Length"));
231236
if ((idx_t)content_length != buffer_out_len) {

0 commit comments

Comments
 (0)