Skip to content

Commit b181e64

Browse files
authored
Merge pull request #461 from DeterminateSystems/eelcodolstra/nix-399
HttpBinaryCacheStore: Don't ignore 401/407 errors
2 parents 3ead6ff + c341e96 commit b181e64

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/libstore/filetransfer.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,12 @@ struct curlFileTransfer : public FileTransfer
685685
if (httpStatus == 404 || httpStatus == 410 || code == CURLE_FILE_COULDNT_READ_FILE) {
686686
// The file is definitely not there
687687
err = NotFound;
688-
} else if (httpStatus == 401 || httpStatus == 403 || httpStatus == 407) {
689-
// Don't retry on authentication/authorization failures
688+
} else if (httpStatus == 401 || httpStatus == 407) {
689+
err = Unauthorized;
690+
} else if (httpStatus == 403) {
691+
// Don't retry on authentication/authorization failures.
692+
// Note: the only reason we treat this differently from 401/407 is S3 returns 403 if a file doesn't
693+
// exist and the bucket is unlistable.
690694
err = Forbidden;
691695
} else if (httpStatus == 429) {
692696
// 429 means too many requests, so we retry (with a substantially longer delay)

src/libstore/include/nix/store/filetransfer.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public:
385385
void
386386
download(FileTransferRequest && request, Sink & sink, std::function<void(FileTransferResult)> resultCallback = {});
387387

388-
enum Error { NotFound, Forbidden, Misc, Transient, Interrupted };
388+
enum Error { NotFound, Unauthorized, Forbidden, Misc, Transient, Interrupted };
389389
};
390390

391391
/**

0 commit comments

Comments
 (0)