From 7808b682bb32cd7a50f17bd5ad3e8a3792c634a1 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Costa Date: Thu, 22 Jan 2026 06:01:26 +0000 Subject: [PATCH] fix(libstore/filetransfer): restart source before upload retries When an upload fails with a transient HTTP error (e.g., S3 rate limiting with HTTP 503), retries would fail with "curl error: Failed to open/read local data from file/application" because the upload source was already exhausted from the previous attempt. Restart the source in init() to ensure it's at the beginning for both first attempts (no-op) and retries (necessary fix). Fixes: #15023 (cherry picked from commit fbd787b9105fc98973e73128289839f28b1b4ca6) --- src/libstore/filetransfer.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 54f423af77e..8a7577146ef 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -450,6 +450,11 @@ struct curlFileTransfer : public FileTransfer curl_easy_setopt(req, CURLOPT_CUSTOMREQUEST, "DELETE"); if (request.data) { + // Restart the source to ensure it's at the beginning. + // This is necessary for retries, where the source was + // already consumed by a previous attempt. + request.data->source->restart(); + if (request.method == HttpMethod::Post) { curl_easy_setopt(req, CURLOPT_POST, 1L); curl_easy_setopt(req, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t) request.data->sizeHint);